+++ /dev/null
-#ifndef __WXBOUNDINGBOX_H__
-#define __WXBOUNDINGBOX_H__
-
-#if defined(__GNUG__) && !defined(__APPLE__)
- #pragma interface "bbox.cpp"
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/wx.h"
-#endif
-
-#include "wx/matrix.h"
-#include "wx/geometry.h"
-
-enum OVERLAP {_IN,_ON,_OUT};
-
-//Purpose The wxBoundingBox class stores one wxBoundingBox.
-//The wxBoundingBox is defined by two coordiates,
-//a upperleft coordinate and a lowerright coordinate.
-class wxBoundingBox
-{
-public:
- wxBoundingBox();
- wxBoundingBox(const wxBoundingBox&);
- wxBoundingBox(const wxPoint2DDouble&);
- wxBoundingBox(double xmin, double ymin, double xmax, double ymax);
-
- bool And(wxBoundingBox*, double Marge = 0);
-
- void EnLarge(const double Marge);
- void Shrink(const double Marge);
-
- void Expand(const wxPoint2DDouble& , const wxPoint2DDouble&);
- void Expand(const wxPoint2DDouble&);
- void Expand(double x,double y);
- void Expand(const wxBoundingBox& bbox);
-
- OVERLAP Intersect( wxBoundingBox &, double Marge = 0);
- bool LineIntersect(const wxPoint2DDouble& begin, const wxPoint2DDouble& end );
- bool PointInBox( const wxPoint2DDouble&, double Marge = 0);
- bool PointInBox( double, double, double Marge = 0);
-
- void Reset();
-
- void Translate( wxPoint2DDouble& );
- void MapBbox( const wxTransformMatrix& matrix);
-
- double GetWidth() {return m_maxx-m_minx;};
- double GetHeight(){return m_maxy-m_miny;};
- bool GetValid() const;
- void SetValid(bool);
-
- void SetBoundingBox(const wxPoint2DDouble& a_point);
-
- void SetMin(double, double);
- void SetMax(double, double);
- inline wxPoint2DDouble GetMin();
- inline wxPoint2DDouble GetMax();
- inline double GetMinX(){return m_minx;};
- inline double GetMinY(){return m_miny;};
- inline double GetMaxX(){return m_maxx;};
- inline double GetMaxY(){return m_maxy;};
-
- wxBoundingBox& operator+( wxBoundingBox& );
- wxBoundingBox& operator=( const wxBoundingBox& );
-
-protected:
- //bounding box in world
- double m_minx;
- double m_miny;
- double m_maxx;
- double m_maxy;
- bool m_validbbox;
-};
-
-#endif
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: canvas.h
-// Author: Robert Roebling
-// Created: XX/XX/XX
-// Copyright: 2000 (c) Robert Roebling
-// Licence: wxWindows Licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef __WXCANVAS_H__
-#define __WXCANVAS_H__
-
-#if defined(__GNUG__) && !defined(__APPLE__)
- #pragma interface "canvas.cpp"
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/wx.h"
-#endif
-
-#include "wx/image.h"
-#include "wx/txtstrm.h"
-#include "wx/geometry.h"
-#include "wx/matrix.h"
-#include "bbox.h"
-
-
-//----------------------------------------------------------------------------
-// decls
-//----------------------------------------------------------------------------
-
-class wxCanvas;
-class wxCanvasAdmin;
-
-//----------------------------------------------------------------------------
-// wxCanvasObject
-//----------------------------------------------------------------------------
-enum wxDRAG_MODE
-{
- wxDRAG_RECTANGLE,
- wxDRAG_ONTOP,
- wxDRAG_REDRAW
-};
-
-//:defenition
-// wxCanvasObject is the base class for Canvas Objects.
-// All Objects for drawing one the canvas are derived from this class.
-// It supports dragging and moving methods that can be used in derived
-// classes for defining several ways of dragging.
-// Also it is possible to plug in events handlers to do this for all derived classes at once.
-//
-// wxCanvasObjects have themselves as their event handlers by default,
-// but their event handlers could be set to another object entirely. This
-// separation can reduce the amount of derivation required, and allow
-// alteration of a wxCanvasObject functionality
-class wxCanvasObject: public wxEvtHandler
-{
- DECLARE_CLASS(wxCanvasObject)
-public:
-
- wxCanvasObject();
-
- //If the position (x,y) is within the object this return a pointer to the object
- //Normally this function needs to be defined for each derived wxCanvasObject.
- //The default is a simple bounding box test.
- virtual wxCanvasObject* IsHitWorld( double x, double y, double margin = 0 );
-
- //render this object to the canvas (either on its buffer or directly on the canvas)
- //this depends on the wxDC that is set for the active canvas.
- virtual void Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height );
-
- //x position in world coordinates of the object
- virtual double GetPosX()=0;
- //y position in world coordinates of the object
- virtual double GetPosY()=0;
-
- //set position in world coordinates for the object
- virtual void SetPosXY( double x, double y)=0;
-
- //absolute moving the object to position x,y in world coordinates
- //also does an update of the old and new area
- virtual void MoveAbsolute( double x, double y );
-
- //relative moving the object to position x,y in world coordinates
- //also does an update of the old and new area
- virtual void MoveRelative( double x, double y );
-
- //relative translate the object to position x,y in world coordinates
- //does NOT update the old and new area
- //this function must be defined for each derived object,
- //it is used internally for dragging and moving objects.
- virtual void TransLate( double x, double y )=0;
-
- //choose one of the three diffrenet drag methods |
- //DRAG_RECTANGLE = as a rectangle when drag is in progress |
- //DRAG_ONTOP = only redraw the object when dragging |
- //DRAG_REDRAW = redraw the damaged areas when dragging
- void SetDragMode(wxDRAG_MODE mode) { m_dragmode=mode; };
-
- //return the dragmode
- wxDRAG_MODE GetDragMode() { return m_dragmode; };
-
- //called when starting a drag
- virtual void DragStart();
- //called when dragging is in progress
- virtual void DragRelative( double x, double y);
- //called when dragging is ended
- virtual void DragEnd();
-
- //return the object if it is part of the given object or
- //if the given object is part of a group within this object.
- //For group objects this means recursively search for it.
- virtual wxCanvasObject* Contains( wxCanvasObject* obj );
-
- //calculate the boundingbox in world coordinates
- virtual void CalcBoundingBox()=0;
-
- //write the object as SVG (scalable vector grafhics
- virtual void WriteSVG( wxTextOutputStream &stream );
-
- //get the administrator for the object,
- //this will give access to the canvas's where it is displayed upon.
- //It is used to render the object to the active canvas.
- //Conversion from world to Device coordinates and visa versa is
- //done using the Active canvas at that moment.
- wxCanvasAdmin *GetAdmin() { return m_admin; }
-
- //set the administrator
- virtual void SetAdmin( wxCanvasAdmin *admin ) { m_admin = admin; }
-
- //is this a control type of canvas object
- bool IsControl() { return m_isControl; }
- //is this a vector type of canvas object
- bool IsVector() { return m_isVector; }
- //is this an Image type of canvas object
- bool IsImage() { return m_isImage; }
-
- //get minimum X of the boundingbox in world coordinates
- inline double GetXMin() { return m_bbox.GetMinX(); }
- //get minimum Y of the boundingbox in world coordinates
- inline double GetYMin() { return m_bbox.GetMinY(); }
- //get maximum X of the boundingbox in world coordinates
- inline double GetXMax() { return m_bbox.GetMaxX(); }
- //get maximum Y of the boundingbox in world coordinates
- inline double GetYMax() { return m_bbox.GetMaxY(); }
-
- //get boundingbox
- inline wxBoundingBox GetBbox() { return m_bbox; }
-
- //redirect all mouse events for the canvas to this object
- void CaptureMouse();
- //release the mouse capture for this object
- void ReleaseMouse();
- //is the mouse captured for this object
- bool IsCapturedMouse();
-
- //set if this object will visible (be rendered or not)
- inline void SetVisible(bool visible) { m_visible=visible; }
- //get visibility
- inline bool GetVisible() {return m_visible; }
-
- //can the object be dragged
- inline void SetDraggable(bool drag) { m_dragable=drag; }
- //get if the object can be dragged
- inline bool GetDraggable() {return m_dragable; }
-
- //get absolute area in the device coordinates where the object
- //its boundingbox in world coordinates is first translated using the matrix.
- wxRect GetAbsoluteArea(const wxTransformMatrix& cworld);
-
- //get currently used eventhandler (always the first in the list)
- wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
-
- //process an event for the object, starting with the first eventhandler
- // in the list.
- bool ProcessCanvasObjectEvent(wxEvent& event);
-
- // push/pop event handler: allows to chain a custom event handler to
- // already existing ones
- void PushEventHandler( wxEvtHandler *handler );
-
- //remove first eventhandler in the list (one will be always stay in)
- wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
- //append an eventhandler to the list, this event handler will be called
- //if the other skipped the event to process.
- void AppendEventHandler(wxEvtHandler *handler);
- //remove last event handler in the list (one will always stay in)
- wxEvtHandler *RemoveLastEventHandler(bool deleteHandler);
-
-protected:
-
- //administator for rendering and accessing the canvas's
- wxCanvasAdmin* m_admin;
-
- //active event handler, default the object itself
- wxEvtHandler* m_eventHandler;
-
- bool m_isControl:1;
- bool m_isVector:1;
- bool m_isImage:1;
- bool m_visible:1;
- bool m_dragable:1;
- wxDRAG_MODE m_dragmode:3;
-
- //boundingbox in world coordinates
- wxBoundingBox m_bbox;
-
- //used for dragging
- wxBitmap m_atnewpos;
-};
-
-//:defenition
-// wxCanvasObjectGroup is a container for wxCanvas derived Objects.
-// It renders itself by calling the render methods of the wxCanvasObjects it contains.
-// It can have nested groups also, in the same way as the other wxCanvasObjects it already contains.
-// The group has a matrix to position/rotate/scale the group.
-class wxCanvasObjectGroup: public wxCanvasObject
-{
- DECLARE_CLASS(wxCanvasObjectGroup)
-public:
- wxCanvasObjectGroup(double x, double y);
- virtual ~wxCanvasObjectGroup();
-
- void SetAdmin(wxCanvasAdmin* admin);
-
- //prepend a wxCanvasObject to this group
- virtual void Prepend( wxCanvasObject* obj );
- //append a wxCanvasObject to this group
- virtual void Append( wxCanvasObject* obj );
- //insert a wxCanvasObject to this group
- virtual void Insert( size_t before, wxCanvasObject* obj );
- //remove the given object from the group
- virtual void Remove( wxCanvasObject* obj );
-
- //those this group contain the given object.
- //in case of nested groups also search in there to the lowwest level.
- virtual wxCanvasObject* Contains( wxCanvasObject* obj );
-
- //returns index of the given wxCanvasObject in this group
- virtual int IndexOf( wxCanvasObject* obj );
-
- double GetPosX() { return lworld.GetValue(2,0); }
- double GetPosY() { return lworld.GetValue(2,1); }
- void SetPosXY( double x, double y) {lworld.SetValue(2,0,x);lworld.SetValue(2,1,y);CalcBoundingBox();};
-
- void TransLate( double x, double y );
-
- void CalcBoundingBox();
- //remove all wxCanvasObjects from the group (flag for deletion of the objectsalso)
- void DeleteContents( bool );
- virtual void Render(wxTransformMatrix* cworld,int x, int y, int width, int height );
- virtual void WriteSVG( wxTextOutputStream &stream );
-
- //recursive call the IsHitWorld on all contained objects, the first
- //one that is hit will be returned
- wxCanvasObject* IsHitWorld( double x, double y, double margin = 0 );
-
- //recursive calls for contained objects to set eventhandlers,
- //and also sets its own eventhandler
- void PushEventHandler( wxEvtHandler *handler );
- //recursive calls for contained objects to set eventhandlers,
- //and also sets its own eventhandler
- wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
- //recursive calls for contained objects to set eventhandlers,
- //and also sets its own eventhandler
- void AppendEventHandler(wxEvtHandler *handler);
- //recursive calls for contained objects to set eventhandlers,
- //and also sets its own eventhandler
- wxEvtHandler *RemoveLastEventHandler(bool deleteHandler);
-
-protected:
-
- //to position the object
- wxTransformMatrix lworld;
-
- wxList m_objects;
-
- friend class wxCanvas;
-};
-
-//:defenition
-// wxCanvasObjectRef is a reference to any wxCanvasObject derived class.
-// It does not duplicate the referenced object.
-// It has a matrix to reposition/rotate/scale the object it references.
-// The position/matrix of the referenced Object is accumulated with the one here.
-class wxCanvasObjectRef: public wxCanvasObject
-{
- DECLARE_CLASS(wxCanvasObjectRef)
-public:
- wxCanvasObjectRef(double x, double y,wxCanvasObject* obj);
-
- //set rotation for the reference
- void SetRotation(double rotation);
-
- //set scale in x and y ( > zero)
- void SetScale( double scalex, double scaley );
-
- void SetAdmin(wxCanvasAdmin* admin);
-
- double GetPosX() { return lworld.GetValue(2,0); }
- double GetPosY() { return lworld.GetValue(2,1); }
- void SetPosXY( double x, double y) {lworld.SetValue(2,0,x);lworld.SetValue(2,1,y);CalcBoundingBox();};
-
- void TransLate( double x, double y );
- void CalcBoundingBox();
- virtual void Render(wxTransformMatrix* cworld,int x, int y, int width, int height );
- virtual void WriteSVG( wxTextOutputStream &stream );
-
- //return this object if one of the objects it references is hit
- wxCanvasObject* IsHitWorld( double x, double y, double margin = 0 );
- virtual wxCanvasObject* Contains( wxCanvasObject* obj );
-
- //recursive calls for contained objects to set eventhandlers,
- //and also sets its own eventhandler
- void PushEventHandler( wxEvtHandler *handler );
- //recursive calls for contained objects to set eventhandlers,
- //and also sets its own eventhandler
- wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
- //recursive calls for contained objects to set eventhandlers,
- //and also sets its own eventhandler
- void AppendEventHandler(wxEvtHandler *handler);
- //recursive calls for contained objects to set eventhandlers,
- //and also sets its own eventhandler
- wxEvtHandler *RemoveLastEventHandler(bool deleteHandler);
-
-protected:
-
- //to position the object
- wxTransformMatrix lworld;
-
- //reference to another wxCanvasObject
- wxCanvasObject* m_obj;
-};
-
-//:defenition
-// wxCanvasRect
-class wxCanvasRect: public wxCanvasObject
-{
- DECLARE_CLASS(wxCanvasRect)
-public:
- wxCanvasRect( double x, double y, double w, double h , double radius=0 );
- void SetBrush( const wxBrush& brush) { m_brush = brush; };
- void SetPen( const wxPen& pen) { m_pen = pen; CalcBoundingBox(); };
-
- double GetPosX() { return m_x; }
- double GetPosY() { return m_y; }
- void SetPosXY( double x, double y) {m_x=x; m_y=y; CalcBoundingBox();};
-
- void TransLate( double x, double y );
- void CalcBoundingBox();
-
- virtual void Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height );
- virtual void WriteSVG( wxTextOutputStream &stream );
-
-private:
- wxPen m_pen;
- wxBrush m_brush;
-
- double m_x;
- double m_y;
- double m_width;
- double m_height;
- double m_radius;
-};
-
-//----------------------------------------------------------------------------
-// wxCanvasCircle
-//----------------------------------------------------------------------------
-class wxCanvasCircle: public wxCanvasObject
-{
-public:
- wxCanvasCircle( double x, double y, double radius );
- void SetBrush( const wxBrush& brush) { m_brush = brush; };
- void SetPen( const wxPen& pen) { m_pen = pen; CalcBoundingBox(); };
-
- double GetPosX() { return m_x; }
- double GetPosY() { return m_y; }
- void SetPosXY( double x, double y) {m_x=x; m_y=y;CalcBoundingBox(); };
-
- void TransLate( double x, double y );
-
- void CalcBoundingBox();
-
- virtual void Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height );
- virtual void WriteSVG( wxTextOutputStream &stream );
-
- wxCanvasObject* IsHitWorld( double x, double y, double margin = 0 );
-
-private:
- wxPen m_pen;
- wxBrush m_brush;
-
- double m_x;
- double m_y;
- double m_radius;
-};
-
-//:defenition
-// wxCanvasEllipse
-class wxCanvasEllipse: public wxCanvasObject
-{
-public:
- wxCanvasEllipse( double x, double y, double width, double height );
- void SetBrush( const wxBrush& brush) { m_brush = brush; };
- void SetPen( const wxPen& pen) { m_pen = pen; CalcBoundingBox(); };
-
- double GetPosX() { return m_x; }
- double GetPosY() { return m_y; }
- void SetPosXY( double x, double y) {m_x=x; m_y=y; CalcBoundingBox();};
-
- void TransLate( double x, double y );
-
- void CalcBoundingBox();
-
- virtual void Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height );
- virtual void WriteSVG( wxTextOutputStream &stream );
-
- wxCanvasObject* IsHitWorld( double x, double y, double margin = 0 );
-
-private:
- wxPen m_pen;
- wxBrush m_brush;
-
- double m_x;
- double m_y;
- double m_width;
- double m_height;
-};
-
-//:defenition
-// wxCanvasEllipticArc
-class wxCanvasEllipticArc: public wxCanvasObject
-{
-public:
- wxCanvasEllipticArc( double x, double y, double width, double height, double start, double end );
- void SetBrush( const wxBrush& brush) { m_brush = brush; };
- void SetPen( const wxPen& pen) { m_pen = pen; CalcBoundingBox(); };
-
- double GetPosX() { return m_x; }
- double GetPosY() { return m_y; }
- void SetPosXY( double x, double y) {m_x=x; m_y=y; CalcBoundingBox();};
-
- void TransLate( double x, double y );
- void CalcBoundingBox();
-
- virtual void Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height );
- virtual void WriteSVG( wxTextOutputStream &stream );
-
- wxCanvasObject* IsHitWorld( double x, double y, double margin = 0 );
-
-private:
- wxPen m_pen;
- wxBrush m_brush;
-
- double m_x;
- double m_y;
- double m_width;
- double m_height;
- double m_start;
- double m_end;
-};
-
-//:defenition
-// wxCanvasLine
-class wxCanvasLine: public wxCanvasObject
-{
-public:
- wxCanvasLine( double x1, double y1, double x2, double y2 );
- void SetPen( const wxPen& pen) { m_pen = pen; CalcBoundingBox(); };
-
-
- double GetPosX() { return m_x1; }
- double GetPosY() { return m_y1; }
- void SetPosXY( double x, double y) {m_x1=x; m_y1=y; CalcBoundingBox();};
-
- void TransLate( double x, double y );
-
- void CalcBoundingBox();
-
- virtual void Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height );
- virtual void WriteSVG( wxTextOutputStream &stream );
-
- wxCanvasObject* IsHitWorld( double x, double y, double margin = 0 );
-
-private:
- wxPen m_pen;
-
- double m_x1;
- double m_y1;
- double m_x2;
- double m_y2;
-};
-
-//:defenition
-// wxCanvasImage
-class wxCanvasImage: public wxCanvasObject
-{
-public:
- wxCanvasImage( const wxImage &image, double x, double y, double w, double h );
-
- double GetPosX() { return m_x; }
- double GetPosY() { return m_y; }
- void SetPosXY( double x, double y);
-
- void TransLate( double x, double y );
-
- void CalcBoundingBox();
-
- virtual void Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height );
- virtual void WriteSVG( wxTextOutputStream &stream );
-
-private:
- double m_x;
- double m_y;
- double m_width;
- double m_height;
-
- wxImage m_image;
- int m_orgw,m_orgh;
-
- // cache
- wxBitmap m_cBitmap;
- wxImage m_cImage;
- int m_cW;
- int m_cH;
- double m_cR;
-};
-
-//----------------------------------------------------------------------------
-// wxCanvasControl
-//----------------------------------------------------------------------------
-
-class wxCanvasControl: public wxCanvasObject
-{
-public:
- wxCanvasControl( wxWindow *control );
- ~wxCanvasControl();
-
- double GetPosX();
- double GetPosY();
- void SetPosXY( double x, double y);
-
- void TransLate( double x, double y );
- void MoveRelative( double x, double y );
-
- void CalcBoundingBox();
-
-private:
- wxWindow *m_control;
-};
-
-//:defenition
-// wxCanvasText
-class wxCanvasText: public wxCanvasObject
-{
-public:
- wxCanvasText( const wxString &text, double x, double y, const wxString &foneFile, int size );
- ~wxCanvasText();
-
- double GetPosX() { return m_x; }
- double GetPosY() { return m_y; }
- void SetPosXY( double x, double y) {m_x=x; m_y=y;CalcBoundingBox(); };
-
- void TransLate( double x, double y );
-
- void CalcBoundingBox();
-
- virtual void Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height );
- virtual void WriteSVG( wxTextOutputStream &stream );
-
- void SetRGB( unsigned char red, unsigned char green, unsigned char blue );
- void SetFlag( int flag );
- int GetFlag() { return m_flag; }
-
-private:
- wxString m_text;
- double m_x;
- double m_y;
- unsigned char *m_alpha;
- void *m_faceData;
- int m_flag;
- int m_red;
- int m_green;
- int m_blue;
- wxString m_fontFileName;
- int m_size;
-};
-
-//:defenition
-// wxCanvas is used to display a wxCanvasGroupObject, which contains wxCanvasObject derived
-// drawable objects. The group to draw is called the root.
-// All objects are defined in world coordinates, relative to its parent (e.g. nested groups)
-// There are methods to convert from world to device coordinates and visa versa.
-// Rendering a draw is normally started on the root, it to a buffer, afterwords
-// an update of the damaged parts will blitted from the buffer to the screen.
-// This is done in Idle time, but can also be forced.
-// World coordinates can be with the Y axis going up are down.
-// The area of the drawing in world coordinates that is visible on the canvas
-// can be set. Parts of this area can be zoomed into resulting in scroll bars
-// to be displayed.
-class wxCanvas: public wxScrolledWindow
-{
-public:
- // constructors and destructors
- wxCanvas( wxCanvasAdmin* admin ,wxWindow *parent, wxWindowID id = -1,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxScrolledWindowStyle );
- virtual ~wxCanvas();
-
- //background colour for the canvas
- virtual void SetColour( const wxColour& background );
-
- //update the area given in device coordinates
- virtual void Update( int x, int y, int width, int height, bool blit = TRUE );
-
- //blit all updated areas now to the screen, else it will happen in idle time.
- //Use this to support dragging for instance, becuase in such cases idle time
- //will take to long.
- virtual void UpdateNow();
-
- //prevent canvas activety
- virtual void Freeze();
- //allow canvas activety
- virtual void Thaw();
-
- //get the buffer that is used for rendering in general
- inline wxBitmap *GetBuffer() { return &m_buffer; }
- //get the DC that is used for rendering
- inline wxDC *GetDC() { return m_renderDC; }
- //set the DC that is used for rendering
- inline void SetDC(wxDC* dc) { m_renderDC=dc; }
-
- inline int GetBufferWidth() { return m_buffer.GetWidth(); }
- inline int GetBufferHeight() { return m_buffer.GetHeight(); }
-
- //updating is needed for the canvas if the buffer did change
- bool NeedUpdate() { return m_needUpdate; }
- bool IsFrozen() { return m_frozen; }
-
- //blit damaged areas in the buffer to the screen
- void BlitBuffer( wxDC &dc );
-
- //redirect events to this canvas object
- void SetCaptureMouse( wxCanvasObject *obj );
- //are events redirected, if so return the object else NULL
- inline wxCanvasObject* GetCaptured() { return m_captureMouse;}
-
- //set the root group where the objects for this canvas are stored
- void SetRoot(wxCanvasObjectGroup* aroot){m_root=aroot;}
-
- //get root group that is displayed on the canvas
- wxCanvasObjectGroup* GetRoot(){return m_root;}
-
- //scroll the window in device coordinates
- virtual void ScrollWindow( int dx, int dy,
- const wxRect* rect = (wxRect *) NULL );
-
- //get y axis orientation
- virtual bool GetYaxis() { return FALSE; }
-
- //get the visible part in world coordinates
- virtual double GetMinX() const;
- virtual double GetMinY() const;
- virtual double GetMaxX() const;
- virtual double GetMaxY() const;
-
- //convert from window to virtual coordinates
- virtual double DeviceToLogicalX(int x) const;
- virtual double DeviceToLogicalY(int y) const;
- virtual double DeviceToLogicalXRel(int x) const;
- virtual double DeviceToLogicalYRel(int y) const;
- virtual int LogicalToDeviceX(double x) const;
- virtual int LogicalToDeviceY(double y) const;
- virtual int LogicalToDeviceXRel(double x) const;
- virtual int LogicalToDeviceYRel(double y) const;
-
-protected:
- wxBitmap m_buffer;
-
- //always available and m_buffer selected
- wxDC* m_renderDC;
-
- bool m_needUpdate;
- wxList m_updateRects;
- wxCanvasObjectGroup* m_root;
-
- wxColour m_background;
- bool m_frozen;
- wxCanvasObject *m_lastMouse;
- wxCanvasObject *m_captureMouse;
-
- int m_oldDeviceX,m_oldDeviceY;
-
- wxCanvasAdmin* m_admin;
-
-private:
- int m_bufferX,m_bufferY;
-
-protected:
- void OnMouse( wxMouseEvent &event );
- void OnPaint( wxPaintEvent &event );
- void OnSize( wxSizeEvent &event );
- void OnIdle( wxIdleEvent &event );
- void OnSetFocus( wxFocusEvent &event );
- void OnKillFocus( wxFocusEvent &event );
- void OnEraseBackground( wxEraseEvent &event );
-
-private:
- DECLARE_CLASS(wxCanvas)
- DECLARE_EVENT_TABLE()
-};
-
-
-
-class wxVectorCanvas: public wxCanvas
-{
-public:
- // constructors and destructors
- wxVectorCanvas( wxCanvasAdmin* admin ,wxWindow *parent, wxWindowID id = -1,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxScrolledWindowStyle );
-
- //scroll the window in device coordinates
- virtual void ScrollWindow( int dx, int dy,
- const wxRect* rect = (wxRect *) NULL );
-
- //set if the Yaxis goes up or down
- void SetYaxis(bool up) { m_yaxis=up; }
-
- //get currently used Yaxis setting
- virtual bool GetYaxis() { return m_yaxis; }
-
- //to set the total area in world coordinates that can be scrolled.
- // when totaly zoomed out (SetMappingScroll same size as given here),
- // this will be the area displayed.
- // To display all of a drawing, set this here to the boundingbox of the root group
- // of the canvas.
- void SetScroll(double vx1,double vy1,double vx2,double vy2);
-
- //given the virtual size to be displayed, the mappingmatrix will be calculated
- //in such a manner that it fits (same ratio in width and height) to the window size.
- //The window size is used to intitialize the mapping.
- //The virtual size is just an indication, it will be ajusted to fit in the client window ratio.
- //When border is set an extra margin is added so that the drawing will fit nicely.
- // To display all of a drawing, set this here to the boundingbox of the root group
- // of the canvas.
- void SetMappingScroll(double vx1,double vy1,double vx2,double vy2,bool border);
-
- //matrix for calculating the virtual coordinate given a screen coordinate
- wxTransformMatrix GetInverseMappingMatrix();
-
- //matrix for calculating the screen coordinate given a virtual coordinate
- wxTransformMatrix GetMappingMatrix();
-
- //get minimum X of the visible part in world coordinates
- virtual double GetMinX() const;
- virtual double GetMinY() const;
- virtual double GetMaxX() const;
- virtual double GetMaxY() const;
-
- //convert from window to virtual coordinates and back
- virtual double DeviceToLogicalX(int x) const;
- virtual double DeviceToLogicalY(int y) const;
- virtual double DeviceToLogicalXRel(int x) const;
- virtual double DeviceToLogicalYRel(int y) const;
- virtual int LogicalToDeviceX(double x) const;
- virtual int LogicalToDeviceY(double y) const;
- virtual int LogicalToDeviceXRel(double x) const;
- virtual int LogicalToDeviceYRel(double y) const;
-
-protected:
- // up or down
- bool m_yaxis;
-
- // holds the matrix for mapping from virtual to screen coordinates
- wxTransformMatrix m_mapping_matrix;
-
- // holds the inverse of the mapping matrix
- wxTransformMatrix m_inverse_mapping;
-
- //virtual coordinates of total drawing
- double m_virtm_minX, m_virtm_minY, m_virtm_maxX, m_virtm_maxY;
-
- // virtual coordinates box
- double m_virt_minX, m_virt_minY, m_virt_maxX, m_virt_maxY;
-
- // bounding box
- double m_minX, m_minY, m_maxX, m_maxY;
-
- //are scroll bars active?
- bool m_scrolled;
-
-private:
- void OnScroll(wxScrollWinEvent& event);
- void OnChar( wxKeyEvent &event );
- void OnSize( wxSizeEvent &event );
-
-private:
- DECLARE_CLASS(wxVectorCanvas)
- DECLARE_EVENT_TABLE()
-};
-
-
-
-//:defenition
-//Contains a list of wxCanvas Objects that will be maintained through this class.
-//Each wxCanvasObject can be displayed on several wxCanvas Objects at the same time.
-//The active wxCanvas is used to render and convert coordinates from world to device.
-//So it is important to set the active wxCanvas based on the wxCanvas that has the focus
-//or is scrolled etc. This is normally done within wxCanvas when appropriate.
-class wxCanvasAdmin
-{
-public:
- // constructors and destructors
- wxCanvasAdmin();
- virtual ~wxCanvasAdmin();
-
- //convert from window to virtual coordinates
- double DeviceToLogicalX(int x) const;
- //convert from window to virtual coordinates
- double DeviceToLogicalY(int y) const;
- //convert from window to virtual coordinates relatif
- double DeviceToLogicalXRel(int x) const;
- //convert from window to virtual coordinates relatif
- double DeviceToLogicalYRel(int y) const;
- //convert from virtual to window coordinates
- int LogicalToDeviceX(double x) const;
- //convert from virtual to window coordinates
- int LogicalToDeviceY(double y) const;
- //convert from virtual to window coordinates relatif
- int LogicalToDeviceXRel(double x) const;
- //convert from virtual to window coordinates relatif
- int LogicalToDeviceYRel(double y) const;
-
- //update in the buffer off all canvases, the area given in world coordinates
- virtual void Update(wxCanvasObject* obj, double x, double y, double width, double height);
-
- //blit all updated areas now to the screen, else it will happen in idle time.
- //Use this to support dragging for instance, becuase in such cases idle time
- //will take to long.
- virtual void UpdateNow();
-
- //append another canvas
- virtual void Append( wxCanvas* canvas );
-
- //remove a canvas
- virtual void Remove( wxCanvas* canvas );
-
- //set the given canvas as active (for rendering, coordinate conversion etc.)
- void SetActive(wxCanvas* activate);
-
- //get active canvas
- inline wxCanvas* GetActive() {return m_active;};
-
-private:
- wxList m_canvaslist;
- wxCanvas* m_active;
-};
-
-#endif
- // WXCANVAS
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: liner.h
-// Author: Klaas Holwerda
-// Created: 1/10/2000
-// Copyright: 2000 (c) Klaas Holwerda
-// Licence: wxWindows Licence
-/////////////////////////////////////////////////////////////////////////////
-#ifndef __WXLINER_H
-#define __WXLINER_H
-
-#if defined(__GNUG__) && !defined(__APPLE__)
- #pragma interface "liner.cpp"
-#endif
-
-
-#include "wx/geometry.h"
-
-enum OUTPRODUCT {R_IS_LEFT,R_IS_ON,R_IS_RIGHT};
-
-// Status of a point to a wxLine
-enum R_PointStatus {R_LEFT_SIDE, R_RIGHT_SIDE, R_ON_AREA, R_IN_AREA};
-
-class wxLine
-{
-public:
- // constructors and destructor
- wxLine( double x1, double y1, double x2, double y2 );
- wxLine( const wxPoint2DDouble& a, const wxPoint2DDouble& b);
- ~wxLine();
-
- wxPoint2DDouble GetBeginPoint(); // Get the beginpoint from a wxLine
- wxPoint2DDouble GetEndPoint(); // Get the endpoint from a wxLine
- bool CheckIntersect( wxLine&, double Marge); // Check if two wxLines intersects
- int Intersect( wxLine&, wxPoint2DDouble& bp ,wxPoint2DDouble& ep ,double Marge) ; // Intersects two wxLines
- bool Intersect( wxLine& lijn, wxPoint2DDouble& crossing); //intersect two (infinit) lines
- R_PointStatus PointOnLine( const wxPoint2DDouble& a_Point, double& Distance, double Marge ); //For an infinite wxLine
- R_PointStatus PointInLine( const wxPoint2DDouble& a_Point, double& Distance, double Marge ); //For a non-infinite wxLine
- OUTPRODUCT OutProduct( const wxLine& two, double accur); // outproduct of two wxLines
- double Calculate_Y( double X); // Caclulate Y if X is known
- void Virtual_Point( wxPoint2DDouble& a_point, double distance) const;
- wxLine& operator=( const wxLine&); // assignment operator
- void CalculateLineParameters(); // Calculate the parameters if nessecary
- void OffsetContour( const wxLine& nextline, double factor,wxPoint2DDouble& offsetpoint) const;
-
-private:
-
- int ActionOnTable1(R_PointStatus,R_PointStatus); // Function needed for Intersect
- int ActionOnTable2(R_PointStatus,R_PointStatus); // Function needed for Intersect
-
- double m_AA;
- double m_BB;
- double m_CC;
- wxPoint2DDouble m_a;
- wxPoint2DDouble m_b;
- bool m_valid_parameters;
-};
-
-#endif
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: polygon.h
-// Author: Klaas Holwerda
-// Created: XX/XX/XX
-// Copyright: 2000 (c) Klaas Holwerda
-// Licence: wxWindows Licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef __WXPOLYGON_H__
-#define __WXPOLYGON_H__
-
-#if defined(__GNUG__) && !defined(__APPLE__)
- #pragma interface "polygon.cpp"
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/wx.h"
-#endif
-
-#include "wx/matrix.h"
-#include "wx/geometry.h"
-#include "bbox.h"
-#include "canvas.h"
-
-enum INOUTPOLY {OUTSIDE_POLY,INSIDE_POLY,ON_POLY};
-
-//----------------------------------------------------------------------------
-// wxCanvasPolygon
-//----------------------------------------------------------------------------
-
-class wxCanvasPolygon: public wxCanvasObject
-{
-public:
- wxCanvasPolygon( int n, wxPoint2DDouble points[], bool spline = FALSE );
- ~wxCanvasPolygon();
- void SetBrush( const wxBrush& brush) { m_brush = brush; }
- void SetPen( const wxPen& pen) { m_pen = pen; CalcBoundingBox(); }
-
- //set colour 1
- //being the background color if filling with a monochrome bitmap
- //or in case of gradient filling the starting colour for the fill
- void SetColour1( const wxColour& fg) { m_textfg=fg;}
- //set colour 1
- //being the foreground color if filling with a monochrome bitmap
- //or in case of gradient filling the ending colour for the fill
- void SetColour2( const wxColour& bg) { m_textbg=bg;}
- //transparent filling when bitmapbrush is monochrome
- void SetTransParent(bool transp) { m_transp=transp;}
- //gradient filling using lines chnging in colour from colour1 to colour2
- void SetGradient(bool gradient, const wxPen& gpen, double distance)
- { m_gradient=gradient;
- m_gpen=gpen;
- m_gdistance=distance;
- }
-
- double GetPosX() { return m_points[0].m_x; }
- double GetPosY() { return m_points[0].m_y; }
- void SetPosXY( double x, double y);
-
- void TransLate( double x, double y );
- void CalcBoundingBox();
-
- virtual void Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height );
- virtual void WriteSVG( wxTextOutputStream &stream );
-
- wxCanvasObject* IsHitWorld( double x, double y, double margin = 0 );
-
- INOUTPOLY PointInPolygon(const wxPoint2DDouble& P, double marge);
-
-private:
-
- bool MoveUp(double horline, int& index, int direction);
- void DetectCriticalPoints();
- void FillPolygon(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height );
- wxList m_CRlist;
- wxList m_AETlist;
-
-
- wxBrush m_brush;
- wxPen m_pen;
- wxColour m_textbg;
- wxColour m_textfg;
-
- //if brush is of type bitmap with a mask fill with mask transparent
- bool m_transp;
- bool m_gradient;
- wxPen m_gpen;
- double m_gdistance;
-
- bool m_spline;
-
- int m_n;
- wxPoint2DDouble* m_points;
-};
-
-//----------------------------------------------------------------------------
-// wxCanvasPolyline
-//----------------------------------------------------------------------------
-
-class wxCanvasPolyline: public wxCanvasObject
-{
-public:
- wxCanvasPolyline(int n, wxPoint2DDouble points[]);
- ~wxCanvasPolyline();
- void SetPen( const wxPen& pen) { m_pen = pen; CalcBoundingBox(); }
-
- double GetPosX() { return m_points[0].m_x; }
- double GetPosY() { return m_points[0].m_y; }
- void SetPosXY( double x, double y);
-
- void TransLate( double x, double y );
- void CalcBoundingBox();
-
- virtual void Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height );
- virtual void WriteSVG( wxTextOutputStream &stream );
-
- wxCanvasObject* IsHitWorld( double x, double y, double margin = 0 );
-
- bool PointOnPolyline(const wxPoint2DDouble& P, double marge);
-
-private:
-
- wxPen m_pen;
-
- int m_n;
- wxPoint2DDouble* m_points;
-};
-
-//----------------------------------------------------------------------------
-// wxCanvasPolygon
-//----------------------------------------------------------------------------
-
-class wxCanvasPolygonL: public wxCanvasObject
-{
-public:
- wxCanvasPolygonL(wxList* points, bool spline = FALSE);
- ~wxCanvasPolygonL();
- void SetBrush( const wxBrush& brush) { m_brush = brush; }
- void SetPen( const wxPen& pen) { m_pen = pen; CalcBoundingBox(); }
- void SetColour1( const wxColour& fg) { m_textfg=fg;}
- void SetColour2( const wxColour& bg) { m_textbg=bg;}
- void SetTransParent(bool transp) { m_transp=transp;}
-
- double GetPosX();
- double GetPosY();
- void SetPosXY( double x, double y);
- void TransLate( double x, double y );
- void CalcBoundingBox();
-
- virtual void Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height );
- virtual void WriteSVG( wxTextOutputStream &stream );
-
- wxCanvasObject* IsHitWorld( double x, double y, double margin = 0 );
-
- INOUTPOLY PointInPolygon(const wxPoint2DDouble& P, double marge);
-
-private:
-
- wxBrush m_brush;
- wxPen m_pen;
- bool m_spline;
- wxColour m_textbg;
- wxColour m_textfg;
- //if brush is of type bitmap with a mask fill with mask transparent
- bool m_transp;
-
- wxList* m_lpoints;
-};
-
-//----------------------------------------------------------------------------
-// wxCanvasPolyline
-//----------------------------------------------------------------------------
-
-class wxCanvasPolylineL: public wxCanvasObject
-{
-public:
- wxCanvasPolylineL(wxList* points, bool spline );
- ~wxCanvasPolylineL();
- void SetPen( const wxPen& pen) { m_pen = pen; CalcBoundingBox(); }
-
- double GetPosX();
- double GetPosY();
- void SetPosXY( double x, double y);
-
- void TransLate( double x, double y );
- void CalcBoundingBox();
-
- virtual void Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height );
- virtual void WriteSVG( wxTextOutputStream &stream );
-
- wxCanvasObject* IsHitWorld( double x, double y, double margin = 0 );
-
- bool PointOnPolyline(const wxPoint2DDouble& P, double marge);
-
-private:
- wxPen m_pen;
- bool m_spline;
-
- wxList* m_lpoints;
-};
-
-//active edge table
-class wxAET
-{
-public:
- inline void CalculateLineParameters( const wxPoint2DDouble& p1 , const wxPoint2DDouble& p2 );
- inline void CalculateXs( double y );
-
- //line paramters
- bool m_horizontal;
- double m_BdivA;
- double m_CdivA;
- int m_index;
- int m_direction;
- //intersection point with scanline;
- double m_xs;
-};
-
-#endif
-
+++ /dev/null
-# $Id$
-
-CONTRIB_SAMPLES=test simple
-
-all:
- @for d in $(CONTRIB_SAMPLES); do (cd $$d && $(MAKE)); done
-
-clean:
- @for d in $(CONTRIB_SAMPLES); do (cd $$d && $(MAKE) clean); done
-
+++ /dev/null
-#
-# File: Makefile.in
-# Author: Julian Smart
-# Created: 2000
-# Updated:
-# Copyright: (c) 2000 Julian Smart
-#
-# "%W% %G%"
-#
-# Makefile for the multicell example (UNIX).
-
-top_srcdir = @top_srcdir@/..
-top_builddir = ../../../..
-program_dir = contrib/samples/canvas/simple
-
-PROGRAM=simple
-
-OBJECTS=simple.o
-
-APPEXTRALIBS=$(top_builddir)/lib/lib@WX_LIBRARY_BASENAME@_canvas-@WX_RELEASE@.@WX_TARGET_LIBRARY_TYPE@
-APPEXTRADEFS=-I$(top_srcdir)/contrib/include
-
-include $(top_builddir)/src/makeprog.env
+++ /dev/null
-# Microsoft Developer Studio Project File - Name="SimpleVC" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-CFG=SimpleVC - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "SimpleVC.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "SimpleVC.mak" CFG="SimpleVC - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "SimpleVC - Win32 Release" (based on "Win32 (x86) Application")
-!MESSAGE "SimpleVC - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE "SimpleVC - Win32 Debug DLL" (based on "Win32 (x86) Application")
-!MESSAGE "SimpleVC - Win32 Release DLL" (based on "Win32 (x86) Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "SimpleVC - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../../include" /I "../../../../contrib/include" /I "../../../../lib/msw" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /i "../../../include" /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxmsw.lib png.lib zlib.lib jpeg.lib tiff.lib regex.lib canvas.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /nodefaultlib:"msvcrtd.lib" /out:"Release/simple.exe" /libpath:"../../../../lib"
-
-!ELSEIF "$(CFG)" == "SimpleVC - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../../../include" /I "../../../../contrib/include" /I "../../../../lib/mswd" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /i "../../../include" /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxmswd.lib pngd.lib zlibd.lib jpegd.lib tiffd.lib regexd.lib canvasd.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /out:"Debug/simple.exe" /pdbtype:sept /libpath:"../../../../lib"
-
-!ELSEIF "$(CFG)" == "SimpleVC - Win32 Debug DLL"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "DebugDLL"
-# PROP BASE Intermediate_Dir "DebugDLL"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "DebugDLL"
-# PROP Intermediate_Dir "DebugDLL"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../../../include" /I "../../../../contrib/include" /I "../../../../lib/mswdlld" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /i "../../../include" /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxmsw250d.lib canvasd.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/simple.exe" /pdbtype:sept /libpath:"../../../../lib"
-
-!ELSEIF "$(CFG)" == "SimpleVC - Win32 Release DLL"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ReleaseDLL"
-# PROP BASE Intermediate_Dir "ReleaseDLL"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "ReleaseDLL"
-# PROP Intermediate_Dir "ReleaseDLL"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../../include" /I "../../../../contrib/include" /I "../../../../lib/mswdll" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /i "../../../include" /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxmsw250.lib canvas.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /out:"ReleaseDLL/simple.exe" /libpath:"../../../../lib"
-
-!ENDIF
-
-# Begin Target
-
-# Name "SimpleVC - Win32 Release"
-# Name "SimpleVC - Win32 Debug"
-# Name "SimpleVC - Win32 Debug DLL"
-# Name "SimpleVC - Win32 Release DLL"
-# Begin Source File
-
-SOURCE=.\simple.cpp
-
-!IF "$(CFG)" == "SimpleVC - Win32 Release"
-
-!ELSEIF "$(CFG)" == "SimpleVC - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "SimpleVC - Win32 Debug DLL"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "SimpleVC - Win32 Release DLL"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\simple.rc
-# ADD BASE RSC /l 0x809
-# ADD RSC /l 0x809 /i "../../../../include" /i "..\..\include"
-# SUBTRACT RSC /i "../../../include"
-# End Source File
-# End Target
-# End Project
+++ /dev/null
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "SimpleVC"=.\SimpleVC.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
+++ /dev/null
-#
-# File: makefile.b32
-# Author: Julian Smart
-# Created: 1999
-# Updated:
-# Copyright:
-#
-# Makefile : Builds sample for 32-bit BC++
-
-WXDIR = $(WXWIN)
-
-TARGET=simple
-
-EXTRALIBS=$(WXDIR)\lib\canvas.lib
-OBJECTS = $(TARGET).obj
-
-!include $(WXDIR)\src\makeprog.b32
-
+++ /dev/null
-# File: makefile.g95 for Plot demo
-# Author: Julian Smart
-# Created: 2001-06-12
-# Updated:
-
-WXDIR = ../../../..
-
-TARGET = simple
-OBJECTS = $(TARGET).o
-EXTRAINC = -I$(WXDIR)/contrib/include
-EXTRALIBS = -lcanvas
-
-include $(WXDIR)/src/makeprog.g95
-
+++ /dev/null
-# File: makefile.vc for Plot sample
-# Author: Julian Smart
-# Created: 2001-06-12
-# Updated:
-
-WXDIR = $(WXWIN)
-PROGRAM = simple
-
-OBJECTS = $(PROGRAM).obj
-EXTRALIBS = $(WXDIR)\lib\canvas$(LIBEXT).lib
-EXTRAINC = -I$(WXDIR)\contrib\include
-
-!include $(WXDIR)\src\makeprog.vc
-
+++ /dev/null
-/* XPM */
-static char *mondrian_xpm[] = {
-/* columns rows colors chars-per-pixel */
-"32 32 6 1",
-" c Black",
-". c Blue",
-"X c #00bf00",
-"o c Red",
-"O c Yellow",
-"+ c Gray100",
-/* pixels */
-" ",
-" oooooo +++++++++++++++++++++++ ",
-" oooooo +++++++++++++++++++++++ ",
-" oooooo +++++++++++++++++++++++ ",
-" oooooo +++++++++++++++++++++++ ",
-" oooooo +++++++++++++++++++++++ ",
-" oooooo +++++++++++++++++++++++ ",
-" oooooo +++++++++++++++++++++++ ",
-" ",
-" ++++++ ++++++++++++++++++ .... ",
-" ++++++ ++++++++++++++++++ .... ",
-" ++++++ ++++++++++++++++++ .... ",
-" ++++++ ++++++++++++++++++ .... ",
-" ++++++ ++++++++++++++++++ .... ",
-" ++++++ ++++++++++++++++++ ",
-" ++++++ ++++++++++++++++++ ++++ ",
-" ++++++ ++++++++++++++++++ ++++ ",
-" ++++++ ++++++++++++++++++ ++++ ",
-" ++++++ ++++++++++++++++++ ++++ ",
-" ++++++ ++++++++++++++++++ ++++ ",
-" ++++++ ++++++++++++++++++ ++++ ",
-" ++++++ ++++++++++++++++++ ++++ ",
-" ++++++ ++++++++++++++++++ ++++ ",
-" ++++++ ++++++++++++++++++ ++++ ",
-" ++++++ ++++ ",
-" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
-" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
-" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
-" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
-" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
-" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
-" "
-};
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: simple.cpp
-// Author: XX
-// Created: XX/XX/XX
-// Copyright:
-/////////////////////////////////////////////////////////////////////////////
-
-#ifdef __GNUG__
- #pragma implementation "simple.cpp"
-#endif
-
-// For compilers that support precompilation
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-// Include private headers
-#include "simple.h"
-
-// Include icon header
-#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__)
- #include "mondrian.xpm"
-#endif
-
-// Include image
-#include "smile.xpm"
-
-// WDR: class implementations
-
-//------------------------------------------------------------------------------
-// MyFrame
-//------------------------------------------------------------------------------
-
-// WDR: event table for MyFrame
-
-BEGIN_EVENT_TABLE(MyFrame,wxFrame)
- EVT_MENU(ID_QUIT, MyFrame::OnQuit)
- EVT_CLOSE(MyFrame::OnCloseWindow)
- EVT_TIMER(-1, MyFrame::OnTimer)
-END_EVENT_TABLE()
-
-MyFrame::MyFrame( wxWindow *parent, wxWindowID id, const wxString &title,
- const wxPoint &position, const wxSize& size, long style ) :
- wxFrame( parent, id, title, position, size, style )
-{
- CreateMyMenuBar();
-
- CreateStatusBar(1);
- SetStatusText( "Welcome to wxCanvas sample!" );
-
- SetIcon(wxICON(mondrian));
-
- // Create wxCanvasAdmin and wxCanvas.
- m_admin = new wxCanvasAdmin;
- wxCanvas *canvas = new wxCanvas( m_admin, this, -1 );
-
- canvas->SetScrollbars( 10, 10, 40, 40 );
-
- // The wxCanvasAdmin need to know about all Admin wxCanvas objects.
- m_admin->Append( canvas );
-
- // One wxCanvas is the active one (current rendering and current
- // world coordinates).
- m_admin->SetActive( canvas );
-
- // One object group is the root in every canvas.
- wxCanvasObjectGroup *root = new wxCanvasObjectGroup(0,0);
- root->DeleteContents( TRUE );
-
- // Bunch of rects and images.
- wxBitmap bitmap( smile_xpm );
- wxImage image( bitmap.ConvertToImage() );
-
- m_smile1 = new wxCanvasImage( image, 0,70,32,32 );
- root->Append( m_smile1 );
-
- wxCanvasCircle *circ = new wxCanvasCircle( 170,70,50 );
- circ->SetBrush( *wxBLUE_BRUSH );
- root->Append( circ );
-
- int i;
- for (i = 10; i < 300; i+=10)
- {
- wxCanvasRect *r = new wxCanvasRect( i,50,3,140 );
- r->SetBrush( *wxRED_BRUSH );
- root->Append( r );
- }
-
- m_smile2 = new wxCanvasImage( image, 0,110,32,32 );
- root->Append( m_smile2 );
-
- for (i = 15; i < 300; i+=10)
- {
- wxCanvasRect *r = new wxCanvasRect( i,50,3,140 );
- r->SetBrush( *wxRED_BRUSH );
- root->Append( r );
- }
-
- // This will call all object and children recursivly so
- // all know what their wxCanvasAdmin is. Call at the end.
- root->SetAdmin( m_admin );
-
- // One object group is the root object.
- canvas->SetRoot( root );
-
- m_timer = new wxTimer( this );
- m_timer->Start( 80, FALSE );
-}
-
-MyFrame::~MyFrame()
-{
- delete m_timer;
-}
-
-void MyFrame::CreateMyMenuBar()
-{
- wxMenu *file_menu = new wxMenu;
- file_menu->Append( ID_QUIT, "Quit...", "Quit program" );
-
- wxMenuBar *menu_bar = new wxMenuBar();
- menu_bar->Append( file_menu, "File" );
-
- SetMenuBar( menu_bar );
-}
-
-// WDR: handler implementations for MyFrame
-
-void MyFrame::OnQuit( wxCommandEvent &event )
-{
- Close( TRUE );
-}
-
-void MyFrame::OnCloseWindow( wxCloseEvent &event )
-{
- // if ! saved changes -> return
-
- Destroy();
-}
-
-void MyFrame::OnTimer( wxTimerEvent &event )
-{
- m_smile1->MoveRelative( 1, 0);
- m_smile2->MoveRelative( 1, 0);
-
- wxWakeUpIdle();
-}
-
-//------------------------------------------------------------------------------
-// MyApp
-//------------------------------------------------------------------------------
-
-IMPLEMENT_APP(MyApp)
-
-MyApp::MyApp()
-{
-}
-
-bool MyApp::OnInit()
-{
- MyFrame *frame = new MyFrame( NULL, -1, "SuperApp", wxPoint(20,20), wxSize(500,340) );
- frame->Show( TRUE );
-
- return TRUE;
-}
-
-int MyApp::OnExit()
-{
- return 0;
-}
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: simple.h
-// Author: XX
-// Created: XX/XX/XX
-// Copyright:
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef __simple_H__
-#define __simple_H__
-
-#if defined(__GNUG__) && !defined(__APPLE__)
- #pragma interface "simple.cpp"
-#endif
-
-// Include wxWindows' headers
-
-#ifndef WX_PRECOMP
- #include <wx/wx.h>
-#endif
-
-#include "wx/canvas/canvas.h"
-#include "wx/timer.h"
-
-//----------------------------------------------------------------------------
-// constants
-//----------------------------------------------------------------------------
-
-#define ID_QUIT 101
-
-// WDR: class declarations
-
-//----------------------------------------------------------------------------
-// MyFrame
-//----------------------------------------------------------------------------
-
-class MyFrame: public wxFrame
-{
-public:
- // constructors and destructors
- MyFrame( wxWindow *parent, wxWindowID id, const wxString &title,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_FRAME_STYLE );
- ~MyFrame();
-
-private:
- // WDR: method declarations for MyFrame
- void CreateMyMenuBar();
-
-private:
- // WDR: member variable declarations for MyFrame
- wxCanvasImage *m_smile1;
- wxCanvasImage *m_smile2;
- wxCanvasAdmin *m_admin;
- wxTimer *m_timer;
-
-private:
- // WDR: handler declarations for MyFrame
- void OnQuit( wxCommandEvent &event );
- void OnCloseWindow( wxCloseEvent &event );
- void OnTimer( wxTimerEvent &event );
-
-private:
- DECLARE_EVENT_TABLE()
-};
-
-//----------------------------------------------------------------------------
-// MyApp
-//----------------------------------------------------------------------------
-
-class MyApp: public wxApp
-{
-public:
- MyApp();
-
- virtual bool OnInit();
- virtual int OnExit();
-};
-
-#endif
+++ /dev/null
-#include "wx/msw/wx.rc"
-
-
+++ /dev/null
-/* XPM */
-static char * smile_xpm[] = {
-/* width height ncolors chars_per_pixel */
-"32 32 4 1",
-/* colors */
-" s None c None",
-". c #000000",
-"+ c #ff0000",
-"@ c #ffff00",
-/* pixels */
-" ........ ",
-" ...@@@@@@@@... ",
-" ..@@@@@@@@@@@@@@.. ",
-" ..@@@@@@@@@@@@@@@@.. ",
-" .@@@@@@@@@@@@@@@@@@@@. ",
-" .@@@@@@@@@@@@@@@@@@@@@@. ",
-" .@@@@@@@@@@@@@@@@@@@@@@@@. ",
-" ..@@@@@@@@@@@@@@@@@@@@@@@@.. ",
-" .@@@@@@@@ @@@@@@ @@@@@@@@. ",
-" .@@@@@@@@ @@@@ @@@@@@@@. ",
-" .@@@@@@@@ @@@@ @@@@@@@@. ",
-" .@@@@@@@@ @@@@ @@@@@@@@. ",
-".@@@@@@@@@ @@@@ @@@@@@@@@.",
-".@@@@@@@@@ @@@@ @@@@@@@@@.",
-".@@@@@@@@@@ @@@@@@ @@@@@@@@@@.",
-".@@@@@@@.@@@@@@@@@@@@@@.@@@@@@@.",
-".@@@@@@@.@@@@@@@@@@@@@@.@@@@@@@.",
-".@@@@@@.@@@@@@@@@@@@@@@@.@@@@@@.",
-".@@@....@@@@@@@@@@@@@@@@....@@@.",
-".@@@@@@@.@@@@@@@@@@@@@@.@@@@@@@.",
-" .@@@@@@@.@@@@@@@@@@@@.@@@@@@@. ",
-" .@@@@@@@..@@@@@@@@@@..@@@@@@@. ",
-" .@@@@@@@@...@@@@@@...@@@@@@@@. ",
-" .@@@@@@@@.+......+.@@@@@@@@. ",
-" ..@@@@@@@@.++++++.@@@@@@@@.. ",
-" .@@@@@@@@@.++++.@@@@@@@@@. ",
-" .@@@@@@@@@....@@@@@@@@@. ",
-" .@@@@@@@@@@@@@@@@@@@@. ",
-" ..@@@@@@@@@@@@@@@@.. ",
-" ..@@@@@@@@@@@@@@.. ",
-" ...@@@@@@@@... ",
-" ........ "};
+++ /dev/null
-#
-# File: Makefile.in
-# Author: Julian Smart
-# Created: 2000
-# Updated:
-# Copyright: (c) 2000 Julian Smart
-#
-# "%W% %G%"
-#
-# Makefile for the multicell example (UNIX).
-
-top_srcdir = @top_srcdir@/..
-top_builddir = ../../../..
-program_dir = contrib/samples/canvas/test
-
-PROGRAM=test
-
-OBJECTS=test.o
-
-DATAFILES = pat4.bmp pat36.bmp
-
-APPEXTRALIBS=$(top_builddir)/lib/lib@WX_LIBRARY_BASENAME@_canvas-@WX_RELEASE@.@WX_TARGET_LIBRARY_TYPE@
-APPEXTRADEFS=-I$(top_srcdir)/contrib/include
-
-include $(top_builddir)/src/makeprog.env
+++ /dev/null
-# Microsoft Developer Studio Project File - Name="TestVC" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-CFG=TestVC - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "TestVC.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "TestVC.mak" CFG="TestVC - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "TestVC - Win32 Release" (based on "Win32 (x86) Application")
-!MESSAGE "TestVC - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE "TestVC - Win32 Debug DLL" (based on "Win32 (x86) Application")
-!MESSAGE "TestVC - Win32 Release DLL" (based on "Win32 (x86) Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "TestVC - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../../include" /I "../../../../contrib/include" /I "../../../../lib/msw" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxmsw.lib png.lib zlib.lib jpeg.lib tiff.lib regex.lib canvas.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /nodefaultlib:"msvcrtd.lib" /out:"Release/test.exe" /libpath:"../../../../lib"
-
-!ELSEIF "$(CFG)" == "TestVC - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../../../include" /I "../../../../contrib/include" /I "../../../../lib/mswd" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxmswd.lib pngd.lib zlibd.lib jpegd.lib tiffd.lib regexd.lib canvasd.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /out:"Debug/test.exe" /pdbtype:sept /libpath:"../../../../lib"
-
-!ELSEIF "$(CFG)" == "TestVC - Win32 Debug DLL"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "DebugDLL"
-# PROP BASE Intermediate_Dir "DebugDLL"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "DebugDLL"
-# PROP Intermediate_Dir "DebugDLL"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../../../include" /I "../../../../contrib/include" /I "../../../../lib/mswdlld" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxmsw250d.lib canvasd.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/test.exe" /pdbtype:sept /libpath:"../../../../lib"
-
-!ELSEIF "$(CFG)" == "TestVC - Win32 Release DLL"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ReleaseDLL"
-# PROP BASE Intermediate_Dir "ReleaseDLL"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "ReleaseDLL"
-# PROP Intermediate_Dir "ReleaseDLL"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../../include" /I "../../../../contrib/include" /I "../../../../lib/mswdll" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxmsw250.lib canvas.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /out:"ReleaseDLL/test.exe" /libpath:"../../../../lib"
-
-!ENDIF
-
-# Begin Target
-
-# Name "TestVC - Win32 Release"
-# Name "TestVC - Win32 Debug"
-# Name "TestVC - Win32 Debug DLL"
-# Name "TestVC - Win32 Release DLL"
-# Begin Source File
-
-SOURCE=.\test.cpp
-
-!IF "$(CFG)" == "TestVC - Win32 Release"
-
-!ELSEIF "$(CFG)" == "TestVC - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "TestVC - Win32 Debug DLL"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "TestVC - Win32 Release DLL"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\test.rc
-# ADD BASE RSC /l 0x809
-# ADD RSC /l 0x809 /i "../../../../include"
-# End Source File
-# End Target
-# End Project
+++ /dev/null
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "TestVC"=.\TestVC.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
+++ /dev/null
-#
-# File: makefile.b32
-# Author: Julian Smart
-# Created: 1999
-# Updated:
-# Copyright:
-#
-# Makefile : Builds sample for 32-bit BC++
-
-WXDIR = $(WXWIN)
-
-TARGET=test
-
-EXTRALIBS=$(WXDIR)\lib\canvas.lib
-OBJECTS = $(TARGET).obj
-
-!include $(WXDIR)\src\makeprog.b32
-
+++ /dev/null
-# File: makefile.g95 for Plot demo
-# Author: Julian Smart
-# Created: 2001-06-12
-# Updated:
-
-WXDIR = ../../../..
-
-TARGET = test
-OBJECTS = $(TARGET).o
-EXTRAINC = -I$(WXDIR)/contrib/include
-EXTRALIBS = -lcanvas
-
-include $(WXDIR)/src/makeprog.g95
-
+++ /dev/null
-# File: makefile.vc for Plot sample
-# Author: Julian Smart
-# Created: 2001-06-12
-# Updated:
-
-WXDIR = $(WXWIN)
-PROGRAM = test
-
-OBJECTS = $(PROGRAM).obj
-EXTRALIBS = $(WXDIR)\lib\canvas$(LIBEXT).lib
-EXTRAINC = -I$(WXDIR)\contrib\include
-
-!include $(WXDIR)\src\makeprog.vc
-
+++ /dev/null
-/* XPM */
-static char * smile_xpm[] = {
-/* width height ncolors chars_per_pixel */
-"32 32 4 1",
-/* colors */
-" s None c None",
-". c #000000",
-"+ c #ff0000",
-"@ c #ffff00",
-/* pixels */
-" ........ ",
-" ...@@@@@@@@... ",
-" ..@@@@@@@@@@@@@@.. ",
-" ..@@@@@@@@@@@@@@@@.. ",
-" .@@@@@@@@@@@@@@@@@@@@. ",
-" .@@@@@@@@@@@@@@@@@@@@@@. ",
-" .@@@@@@@@@@@@@@@@@@@@@@@@. ",
-" ..@@@@@@@@@@@@@@@@@@@@@@@@.. ",
-" .@@@@@@@@ @@@@@@ @@@@@@@@. ",
-" .@@@@@@@@ @@@@ @@@@@@@@. ",
-" .@@@@@@@@ @@@@ @@@@@@@@. ",
-" .@@@@@@@@ @@@@ @@@@@@@@. ",
-".@@@@@@@@@ @@@@ @@@@@@@@@.",
-".@@@@@@@@@ @@@@ @@@@@@@@@.",
-".@@@@@@@@@@ @@@@@@ @@@@@@@@@@.",
-".@@@@@@@.@@@@@@@@@@@@@@.@@@@@@@.",
-".@@@@@@@.@@@@@@@@@@@@@@.@@@@@@@.",
-".@@@@@@.@@@@@@@@@@@@@@@@.@@@@@@.",
-".@@@....@@@@@@@@@@@@@@@@....@@@.",
-".@@@@@@@.@@@@@@@@@@@@@@.@@@@@@@.",
-" .@@@@@@@.@@@@@@@@@@@@.@@@@@@@. ",
-" .@@@@@@@..@@@@@@@@@@..@@@@@@@. ",
-" .@@@@@@@@...@@@@@@...@@@@@@@@. ",
-" .@@@@@@@@.+......+.@@@@@@@@. ",
-" ..@@@@@@@@.++++++.@@@@@@@@.. ",
-" .@@@@@@@@@.++++.@@@@@@@@@. ",
-" .@@@@@@@@@....@@@@@@@@@. ",
-" .@@@@@@@@@@@@@@@@@@@@. ",
-" ..@@@@@@@@@@@@@@@@.. ",
-" ..@@@@@@@@@@@@@@.. ",
-" ...@@@@@@@@... ",
-" ........ "};
+++ /dev/null
-/*
- * Program: canvas
- *
- * Author: Robert Roebling
- *
- * Copyright: (C) 1998, Robert Roebling
- *
- */
-
-#ifdef __GNUG__
- #pragma implementation "test.cpp"
-#endif
-
-// For compilers that support precompilation
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "test.h"
-#include "smile.xpm"
-
-//-----------------------------------------------------
-// class MywxCanvasObjectRef
-//-----------------------------------------------------
-
-BEGIN_EVENT_TABLE(MywxCanvasObjectRef,wxCanvasObjectRef)
- EVT_MOUSE_EVENTS( MywxCanvasObjectRef::OnMouseEvent )
-END_EVENT_TABLE()
-
-IMPLEMENT_DYNAMIC_CLASS(MywxCanvasObjectRef, wxCanvasObjectRef)
-
-MywxCanvasObjectRef::MywxCanvasObjectRef(double x, double y,wxCanvasObjectGroup* group)
- :wxCanvasObjectRef(x,y,group)
-{
-}
-
-MywxCanvasObjectRef::MywxCanvasObjectRef()
- :wxCanvasObjectRef(0,0,NULL)
-{
-}
-
-MywxCanvasObjectRef::~MywxCanvasObjectRef()
-{
-}
-
-void MywxCanvasObjectRef::OnMouseEvent(wxMouseEvent &event)
-{
- if (!m_dragable)
- {
- event.Skip();
- return;
- }
-
- static double xprev;
- static double yprev;
-
- //new position of the mouse relative within the object
- double x = m_admin->DeviceToLogicalX(event.GetX());
- double y = m_admin->DeviceToLogicalY(event.GetY());
-
- if (event.LeftDown())
- {
- CaptureMouse();
- if (m_dragmode != wxDRAG_REDRAW)
- DragStart();
- }
- else if (event.LeftUp())
- {
- ReleaseMouse();
- if (m_dragmode != wxDRAG_REDRAW)
- DragEnd();
- }
- else if (IsCapturedMouse())
- {
- if (m_dragmode != wxDRAG_REDRAW)
- DragRelative(x-xprev,y-yprev);
- else
- MoveRelative(x-xprev,y-yprev);
- m_admin->UpdateNow();
- }
- xprev=x;
- yprev=y;
- //well do something extra
- if (IsCapturedMouse())
- m_admin->GetActive()->SetCursor(*wxHOURGLASS_CURSOR);
- else
- m_admin->GetActive()->SetCursor(*wxSTANDARD_CURSOR);
-}
-
-//---------------------------------------------------
-// class MyEventHandler
-//---------------------------------------------------
-
-BEGIN_EVENT_TABLE(MyEventHandler,wxEvtHandler)
- EVT_MOUSE_EVENTS( MyEventHandler::OnMouseEvent )
-END_EVENT_TABLE()
-
-MyEventHandler::MyEventHandler()
-{
-}
-
-void MyEventHandler::OnMouseEvent(wxMouseEvent &event)
-{
- wxCanvasObject* obj=(wxCanvasObject*)event.GetEventObject();
-
- if (!obj->GetDraggable())
- return;
-
- static double xprev;
- static double yprev;
-
- wxCanvasAdmin* adm=obj->GetAdmin();
-
- //new position of the mouse relative within the object
- double x = adm->DeviceToLogicalX(event.GetX());
- double y = adm->DeviceToLogicalY(event.GetY());
-
- if (event.LeftDown())
- {
- obj->CaptureMouse();
- if (obj->GetDragMode() != wxDRAG_REDRAW)
- obj->DragStart();
- }
- else if (event.LeftUp())
- {
- obj->ReleaseMouse();
- if (obj->GetDragMode() != wxDRAG_REDRAW)
- obj->DragEnd();
- }
- else if (obj->IsCapturedMouse())
- {
- if (obj->GetDragMode() != wxDRAG_REDRAW)
- obj->DragRelative(x-xprev,y-yprev);
- else
- obj->MoveRelative(x-xprev,y-yprev);
- adm->UpdateNow();
- }
- xprev=x;
- yprev=y;
- //well do something extra
- if (obj->IsCapturedMouse())
- obj->GetAdmin()->GetActive()->SetCursor(*wxHOURGLASS_CURSOR);
- else
- obj->GetAdmin()->GetActive()->SetCursor(*wxSTANDARD_CURSOR);
-}
-
-//------------------------------------------------
-// class MyFrame
-//------------------------------------------------
-
-class MyApp;
-class MyCanvas;
-
-BEGIN_EVENT_TABLE(MyFrame, wxFrame)
- EVT_MENU(SPLIT_VERTICAL, MyFrame::SplitVertical)
- EVT_MENU(SPLIT_HORIZONTAL, MyFrame::SplitHorizontal)
- EVT_MENU(SPLIT_UNSPLIT, MyFrame::Unsplit)
- EVT_MENU(SPLIT_QUIT, MyFrame::Quit)
- EVT_MENU(SPLIT_SETMINSIZE, MyFrame::SetMinSize)
-
- EVT_UPDATE_UI(SPLIT_VERTICAL, MyFrame::UpdateUIVertical)
- EVT_UPDATE_UI(SPLIT_HORIZONTAL, MyFrame::UpdateUIHorizontal)
- EVT_UPDATE_UI(SPLIT_UNSPLIT, MyFrame::UpdateUIUnsplit)
-
- EVT_MENU (ID_ABOUT, MyFrame::OnAbout)
- EVT_TIMER (-1, MyFrame::OnTimer)
-END_EVENT_TABLE()
-
-// My frame constructor
-MyFrame::MyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos, const wxSize& size):
- wxFrame(frame, SPLITTER_FRAME, title, pos, size)
-{
- m_eventhandler =new MyEventHandler();
-
- wxPathList pathList;
- pathList.Add(".");
- pathList.Add("..");
-
- wxString path = pathList.FindValidPath("pat36.bmp");
- gs_bmp36_mono.LoadFile(path, wxBITMAP_TYPE_BMP);
- wxMask* mask36 = new wxMask(gs_bmp36_mono, *wxBLACK);
- /* associate a monochrome mask with this bitmap */
- gs_bmp36_mono.SetMask(mask36);
-
- CreateStatusBar(2);
-
- // Make a menubar
- fileMenu = new wxMenu;
- fileMenu->Append(SPLIT_VERTICAL, "Split &Vertically\tCtrl-V", "Split vertically");
- fileMenu->Append(SPLIT_HORIZONTAL, "Split &Horizontally\tCtrl-H", "Split horizontally");
- fileMenu->Append(SPLIT_UNSPLIT, "&Unsplit", "Unsplit");
-// fileMenu->Append(SPLIT_UNSPLIT, "&Unsplit\tCtrl-U", "Unsplit");
- fileMenu->AppendSeparator();
- fileMenu->Append(SPLIT_SETMINSIZE, "Set &min size", "Set minimum pane size");
- fileMenu->AppendSeparator();
- fileMenu->Append(SPLIT_QUIT, "E&xit\tAlt-X", "Exit");
- fileMenu->Append( ID_ABOUT, "&About...");
-
-
- menuBar = new wxMenuBar;
- menuBar->Append(fileMenu, "&File");
-
- SetMenuBar(menuBar);
-
- m_splitter = new MySplitterWindow(this, SPLITTER_WINDOW);
-
- m_canvas1 = new MyCanvas(&m_canvasadmin, m_splitter, CANVAS1, wxPoint(0, 0), wxSize(400, 400),wxHSCROLL|wxVSCROLL);
- m_canvas1->SetYaxis(FALSE);
- m_canvas1->SetMappingScroll(-300,-300,500,500,false);
- m_canvas1->SetScroll(-400,-400,600,600);
- m_canvas1->SetColour(wxColour(255, 255, 255) );
- m_canvas1->SetCursor(wxCursor(wxCURSOR_MAGNIFIER));
-
- m_canvas2 = new MyCanvas(&m_canvasadmin, m_splitter, CANVAS2, wxPoint(0, 0), wxSize(400, 400),wxHSCROLL|wxVSCROLL);
- m_canvas2->SetMappingScroll(-100,-100,500,500,false);
- m_canvas2->SetScroll(-400,-400,600,600);
- m_canvas2->SetColour( wxColour(187, 215, 243) );
- m_canvas2->Show(FALSE);
-
- m_canvasadmin.Append(m_canvas1);
- m_canvasadmin.Append(m_canvas2);
- m_canvasadmin.SetActive(m_canvas1);
-
- m_splitter->Initialize(m_canvas1);
- SetStatusText("Min pane size = 0", 1);
-
- int widths[] = { -1, 100 };
- SetStatusWidths( 2, widths );
-
- //root group always at 0,0
- m_datatree = new wxCanvasObjectGroup(0,0);
- m_datatree->DeleteContents( TRUE );
- m_datatree->SetAdmin(&m_canvasadmin);
-
- wxBitmap bitmap( smile_xpm );
- wxImage image( bitmap.ConvertToImage() );
-
-// m_sm1 = new wxCanvasImage( image, 0,70,32,32 );
-// m_datatree->Append( m_sm1 );
-
- int i;
- for (i = 10; i < 300; i+=10)
- {
- wxCanvasRect *r = new wxCanvasRect( i,50,3,140 );
- r->SetBrush( *wxRED_BRUSH );
- m_datatree->Append( r );
- }
-
-
-// m_sm2 = new wxCanvasImage( image, 0,140,24,24 );
-// m_datatree->Append( m_sm2 );
-
- for (i = 15; i < 300; i+=10)
- {
- wxCanvasRect* rec= new wxCanvasRect( i,50,3,140 );
- rec->SetBrush(wxBrush(wxColour(0,10+i,2+i),wxSOLID));
- rec->SetDraggable(FALSE);
- m_datatree->Append( rec );
- }
-
-/*
- wxButton *button = new wxButton( m_canvas1, -1, "Hello", wxPoint(80,50) );
- m_datatree->Append( new wxCanvasControl( button ) );
-
- m_datatree->Append( new wxCanvasText( "Hello", 180, 50,
- wxGetApp().GetFontPath() + "/times.ttf", 20 ) );
-
- m_datatree->Append( new wxCanvasText( "How are you?", 180, 10,
- wxGetApp().GetFontPath() + "/times.ttf", 8 ) );
-
- m_datatree->Append( new wxCanvasText( "How are you?", 180, 20,
- wxGetApp().GetFontPath() + "/times.ttf", 10 ) );
-
- m_datatree->Append( new wxCanvasText( "How are you?", 180, 30,
- wxGetApp().GetFontPath() + "/times.ttf", 12 ) );
- m_sm3 = new wxCanvasImage( image, 0,210,32,32 );
- m_datatree->Append( m_sm3 );
-*/
- for (i = 10; i < 300; i+=10)
- m_datatree->Append( new wxCanvasLine( 10,-15,i,300 ) );
-/*
- m_sm4 = new wxCanvasImage( image, 0,270,64,32 );
- m_sm4->SetDragMode(wxDRAG_RECTANGLE);
- m_datatree->Append( m_sm4 );
-*/
-
-// m_canvas->Append( new wxCanvasLine( 10,-1500e6,50,300000e6, 0,255,0 ) );
-// m_canvas->Append( new wxCanvasLine( 10,-150000,50,300000, 0,255,0 ) );
-
-
- //make a group of wxCanvasObjects
- wxCanvasObjectGroup* group1 = new wxCanvasObjectGroup(0,0);
-
- wxCanvasLine* line = new wxCanvasLine( 10,-35,50,190);
- line->SetPen(wxPen(wxColour(255,161,5),5,wxDOT_DASH ));
- group1->Prepend( line );
- group1->Prepend( new wxCanvasImage( image, 4,38,32,32 ) );
- wxCanvasRect* rec3 = new wxCanvasRect(20,-20,50,170);
- rec3->SetBrush(wxBrush(wxColour(0,120,240),wxSOLID));
- rec3->SetPen(wxPen(wxColour(252,54,252 ),3,wxSOLID));
- group1->Prepend( rec3 );
-
- wxCanvasRect* rec2 = new wxCanvasRect(10,20,104,52);
- rec2->SetBrush(wxBrush(wxColour(0,240,240),wxSOLID));
- rec2->SetPen(wxPen(wxColour(210,40,50 ),1,wxSOLID));
- group1->Prepend( rec2 );
-
-
-
- wxPoint2DDouble* todraw2 = new wxPoint2DDouble[3];
- todraw2[0].m_x=230;
- todraw2[0].m_y=220;
- todraw2[1].m_x=300;
- todraw2[1].m_y=200;
- todraw2[2].m_x=300;
- todraw2[2].m_y=300;
- wxCanvasPolyline* poly2= new wxCanvasPolyline(3,todraw2);
- poly2->SetPen(wxPen(wxColour(200,0,64 ),4,wxDOT));
- m_datatree->Prepend( poly2 );
-
-
-
- //make another group of wxCanvasObjects
- wxCanvasObjectGroup* group2 = new wxCanvasObjectGroup(0,0);
- group2->Prepend( new wxCanvasImage( image, 60,38,52,32 ) );
- wxCanvasRect* rr = new wxCanvasRect(10,20,104,52,30);
- rr->SetBrush(wxBrush(wxColour(10,17,255),wxHORIZONTAL_HATCH ));
- rr->SetPen(wxPen(wxColour(9,115,64 ),4,wxSOLID));
- group2->Prepend( rr );
-
-
- //this a reference to group2 put into group1
- MywxCanvasObjectRef* m_subref = new MywxCanvasObjectRef(60,50, group2);
- m_subref->SetRotation(35);
- m_subref->SetRotation(0);
- group1->Prepend( m_subref );
-
-
- wxPoint2DDouble* todraw = new wxPoint2DDouble[5];
- todraw[0].m_x=-30;
- todraw[0].m_y=-20;
- todraw[1].m_x=100;
- todraw[1].m_y=0;
- todraw[2].m_x=100;
- todraw[2].m_y=100;
- todraw[3].m_x=50;
- todraw[3].m_y=150;
- todraw[4].m_x=0;
- todraw[4].m_y=100;
-
- wxCanvasPolygon* poly= new wxCanvasPolygon(5,todraw);
- poly->SetBrush(wxBrush(wxColour(100,17,255),wxCROSSDIAG_HATCH ));
- poly->SetPen(wxPen(wxColour(9,115,64 ),4,wxSOLID));
- group1->Prepend( poly );
-
- wxPoint2DDouble* todraw4 = new wxPoint2DDouble[4];
-
- todraw4[0].m_x=-50;
- todraw4[0].m_y=-30;
- todraw4[1].m_x=-50;
- todraw4[1].m_y=70;
- todraw4[2].m_x=150;
- todraw4[2].m_y=70;
- todraw4[3].m_x=150;
- todraw4[3].m_y=-30;
-
- wxCanvasPolygon* poly5= new wxCanvasPolygon(4,todraw4);
- poly5->SetBrush(wxBrush(wxColour(100,17,255),wxCROSSDIAG_HATCH ));
-// poly5->SetBrush(wxBrush(wxColour(100,17,255),wxSOLID ));
-// poly5->SetPen(wxPen(wxColour(9,115,64 ),1,wxSOLID));
- poly5->SetPen(wxPen(wxColour(9,115,64 ),4,wxSOLID));
- wxCanvasObjectGroup* group3 = new wxCanvasObjectGroup(0,0);
- group3->Prepend( poly5 );
-
- wxList* pointlist = new wxList();
- wxPoint2DDouble* point = new wxPoint2DDouble(0,0);
- pointlist->Append((wxObject*)point);
- point = new wxPoint2DDouble(-300,100);
- pointlist->Append((wxObject*)point);
- point = new wxPoint2DDouble(-100,100);
- pointlist->Append((wxObject*)point);
- point = new wxPoint2DDouble(-100,0);
- pointlist->Append((wxObject*)point);
- point = new wxPoint2DDouble(-200,50);
- pointlist->Append((wxObject*)point);
-
- wxCanvasPolygonL* poly15= new wxCanvasPolygonL(pointlist,TRUE);
- poly15->SetColour1(wxColour(250,78,216 ));
- poly15->SetColour2(*wxRED);
- poly15->SetBrush(wxBrush(gs_bmp36_mono));
- poly15->SetTransParent(TRUE);
- poly15->SetPen(wxPen(*wxRED,4,wxSOLID));
- group1->Prepend( poly15 );
-
- wxList* pointlist2 = new wxList();
- wxPoint2DDouble* point2 = new wxPoint2DDouble(-400,100);
- pointlist2->Append((wxObject*)point2);
- point2 = new wxPoint2DDouble(-400,200);
- pointlist2->Append((wxObject*)point2);
- point2 = new wxPoint2DDouble(0,200);
- pointlist2->Append((wxObject*)point2);
- point2 = new wxPoint2DDouble(0,100);
- pointlist2->Append((wxObject*)point2);
- point2 = new wxPoint2DDouble(-200,175);
- pointlist2->Append((wxObject*)point2);
-
- wxCanvasPolylineL* poly16= new wxCanvasPolylineL(pointlist2,TRUE);
- poly16->SetPen(wxPen(wxColour(9,115,64 ),4,wxSOLID));
- m_datatree->Prepend( poly16 );
-
-
- wxPoint2DDouble* todraw6 = new wxPoint2DDouble[5];
- todraw6[0].m_x=50;
- todraw6[0].m_y=305;
- todraw6[1].m_x=-200;
- todraw6[1].m_y=200;
- todraw6[2].m_x=0;
- todraw6[2].m_y=500;
- todraw6[3].m_x=300;
- todraw6[3].m_y=200;
- todraw6[4].m_x=-300;
- todraw6[4].m_y=-300;
-
- wxCanvasPolygon* poly17= new wxCanvasPolygon(5,todraw6,TRUE);
- poly17->SetBrush(wxBrush(wxColour(100,17,255),wxSOLID));
- poly17->SetPen(wxPen(wxColour(10,17,25),16,wxLONG_DASH ));
- poly17->SetColour1(*wxGREEN);
- poly17->SetColour2(*wxRED);
- poly17->SetGradient(TRUE,wxPen(wxColour(0,0,0),0,wxSOLID),0);
- wxCanvasObjectRef* m_refc = new wxCanvasObjectRef(0,-200, poly17);
- m_refc->SetRotation(90);
- m_datatree->Prepend( m_refc );
- wxCanvasObjectRef* m_refd = new wxCanvasObjectRef(200,-50, poly17);
- m_refd->SetRotation(0);
- m_datatree->Append( m_refd );
-
- //now make two references to group1 into root group of the canvas
- m_ref = new MywxCanvasObjectRef(350,-200, group1);
- m_ref->SetRotation(25);
- //TODO if rotation is 0 scaling is weird
-// m_ref->SetScale(2,3.2);
- m_datatree->Append( m_ref );
-
- group3->Prepend( m_ref );
-
-
- //this a reference to group2 put into group1
- MywxCanvasObjectRef* subref2 = new MywxCanvasObjectRef(20,130, group2);
- subref2->SetRotation(15);
- group3->Prepend( subref2 );
- m_datatree->Prepend( subref2 );
-
- m_ref2 = new MywxCanvasObjectRef(80,450, group1);
- m_ref2->SetRotation(-35);
- m_ref2->SetDragMode(wxDRAG_RECTANGLE);
- m_datatree->Prepend( m_ref2 );
-
- wxCanvasCircle* cir = new wxCanvasCircle( -100, -150, 100 );
- cir->SetBrush(wxBrush(wxColour(19,215,6),wxHORIZONTAL_HATCH ));
- cir->SetPen(wxPen(wxColour(198,3,105 ),30,wxSOLID));
- cir->SetDragMode(wxDRAG_REDRAW);
- m_datatree->Prepend( cir );
-
- wxCanvasEllipse* elp = new wxCanvasEllipse( -100, 250, 100,300 );
- elp->SetBrush(wxBrush(wxColour(100,17,55),wxVERTICAL_HATCH ));
- elp->SetPen(wxPen(wxColour(2,255,6 ),10,wxDOT));
- m_datatree->Prepend( elp );
-
- wxCanvasEllipticArc* aelp = new wxCanvasEllipticArc( -230, 250, 100,300, 30,270 );
- aelp->SetBrush(wxBrush(wxColour(100,17,155),wxSOLID ));
- aelp->SetPen(wxPen(wxColour(1,215,6 ),10,wxSOLID));
- m_datatree->Prepend( aelp );
-
- //HOW BAD DO THINGS GET
- int kk;
- for (kk=0;kk<100;kk++)
- {
-// MywxCanvasObjectRef* m_refx = new MywxCanvasObjectRef(180,50+kk*30, group1);
-// m_refx->SetRotation(-35);
-// m_datatree->Prepend( m_refx );
- }
-
-/*
- m_log = new wxTextCtrl( this, -1, "", wxPoint(0,0), wxSize(100,100), wxTE_MULTILINE );
- wxLog *old_log = wxLog::SetActiveTarget( new wxLogTextCtrl( m_log ) );
- delete old_log;
-
- wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
-
- topsizer->Add( m_canvas, 1, wxEXPAND );
- topsizer->Add( m_log, 0, wxEXPAND );
-
- SetAutoLayout( TRUE );
- SetSizer( topsizer );
-*/
-
- //fancy background
- wxPoint2DDouble* todraw8 = new wxPoint2DDouble[4];
- todraw8[0].m_x=-350;
- todraw8[0].m_y=-350;
- todraw8[1].m_x=-350;
- todraw8[1].m_y=550;
- todraw8[2].m_x=550;
- todraw8[2].m_y=550;
- todraw8[3].m_x=550;
- todraw8[3].m_y=-350;
-
- wxCanvasPolygon* poly18= new wxCanvasPolygon(4,todraw8);
- poly18->SetPen(wxPen(wxColour(10,17,25),16,wxTRANSPARENT ));
- poly18->SetColour1(wxColour(0,0,0));
- poly18->SetColour2(wxColour(0,255,255));
- poly18->SetGradient(TRUE,wxPen(wxColour(0,0,0),0,wxSOLID),0);
-
- wxCanvasObjectRef* m_refb = new wxCanvasObjectRef(200,0, poly18);
- m_refb->SetRotation(90);
-
- m_datatree->Prepend( m_refb );
-
-/*
- wxCanvasCircle* cir = new wxCanvasCircle( -100, -150, 100 );
- cir->SetBrush(wxBrush(wxColour(19,215,6),wxHORIZONTAL_HATCH ));
- cir->SetPen(wxPen(wxColour(198,3,105 ),30,wxSOLID));
- m_datatree->Prepend( cir );
-*/
- m_datatree->SetAdmin(&m_canvasadmin);
- m_datatree->AppendEventHandler( m_eventhandler );
- m_canvas1->SetRoot(m_datatree);
-
- //wxCanvasObjectGroup* group3 = new wxCanvasObjectGroup(0,0);
- // group3->Prepend( cir );
-
- group3->SetAdmin(&m_canvasadmin);
- m_canvas2->SetRoot(group3);
-
- m_timer = new wxTimer( this );
- //m_timer->Start( 100, FALSE );
-}
-
-MyFrame::~MyFrame()
-{
- m_datatree->RemoveLastEventHandler( FALSE );
- delete m_eventhandler;
- delete m_timer;
-}
-
-void MyFrame::Quit(wxCommandEvent& WXUNUSED(event) )
-{
- Close(TRUE);
-}
-
-void MyFrame::SplitHorizontal(wxCommandEvent& WXUNUSED(event) )
-{
- if ( m_splitter->IsSplit() )
- m_splitter->Unsplit();
- m_canvas1->Show(TRUE);
- m_canvas2->Show(TRUE);
- m_splitter->SplitHorizontally( m_canvas1, m_canvas2 );
- UpdatePosition();
-}
-
-void MyFrame::SplitVertical(wxCommandEvent& WXUNUSED(event) )
-{
- if ( m_splitter->IsSplit() )
- m_splitter->Unsplit();
- m_canvas1->Show(TRUE);
- m_canvas2->Show(TRUE);
- m_splitter->SplitVertically( m_canvas1, m_canvas2 );
- UpdatePosition();
-}
-
-void MyFrame::Unsplit(wxCommandEvent& WXUNUSED(event) )
-{
- if ( m_splitter->IsSplit() )
- m_splitter->Unsplit();
- SetStatusText("No splitter");
-}
-
-void MyFrame::SetMinSize(wxCommandEvent& WXUNUSED(event) )
-{
- wxString str;
- str.Printf( _T("%d"), m_splitter->GetMinimumPaneSize());
- str = wxGetTextFromUser("Enter minimal size for panes:", "", str, this);
- if ( str.IsEmpty() )
- return;
-
- int minsize = wxStrtol( str, (wxChar**)NULL, 10 );
- m_splitter->SetMinimumPaneSize(minsize);
- str.Printf( _T("Min pane size = %d"), minsize);
- SetStatusText(str, 1);
-}
-
-void MyFrame::UpdateUIHorizontal(wxUpdateUIEvent& event)
-{
- event.Enable( ( (!m_splitter->IsSplit()) || (m_splitter->GetSplitMode() != wxSPLIT_HORIZONTAL) ) );
-}
-
-void MyFrame::UpdateUIVertical(wxUpdateUIEvent& event)
-{
- event.Enable( ( (!m_splitter->IsSplit()) || (m_splitter->GetSplitMode() != wxSPLIT_VERTICAL) ) );
-}
-
-void MyFrame::UpdateUIUnsplit(wxUpdateUIEvent& event)
-{
- event.Enable( m_splitter->IsSplit() );
-}
-
-void MyFrame::UpdatePosition()
-{
- wxString str;
- str.Printf( "Sash position = %d", m_splitter->GetSashPosition());
- SetStatusText(str);
-}
-
-void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) )
-{
- Close( TRUE );
-}
-
-void MyFrame::OnTimer( wxTimerEvent &WXUNUSED(event) )
-{
- m_sm1->MoveRelative( 1, 0);
- m_sm2->MoveRelative( 1, 0);
- m_sm3->MoveRelative( 1, 0);
- m_sm4->MoveRelative( 2, 0);
-
-// m_ref->MoveRelative( 1, 0 );
- m_ref2->MoveRelative( 2, 0 );
- m_canvas1->UpdateNow();
-
-
- wxWakeUpIdle();
-}
-
-void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
-{
- (void)wxMessageBox( "wxCanvas demo\n"
- "Robert Roebling (c) 1998,2000 \n Modified by Klaas Holwerda 2000",
- "About wxCanvas Demo", wxICON_INFORMATION | wxOK );
-}
-
-
-//------------------------------------------------
-// class MyCanvas
-//------------------------------------------------
-
-// the event tables connect the wxWindows events with the functions (event
-// handlers) which process them.
-BEGIN_EVENT_TABLE(MyCanvas,wxVectorCanvas)
- EVT_MOUSE_EVENTS (MyCanvas::OnMouseEvent)
-END_EVENT_TABLE()
-
-MyCanvas::MyCanvas(wxCanvasAdmin* admin, MySplitterWindow *parent, wxWindowID id,
- const wxPoint &position, const wxSize& size, long style ) :
- wxVectorCanvas( admin, parent, id, position, size, style )
-{
- m_parent=parent;
-}
-
-void MyCanvas::OnMouseEvent(wxMouseEvent& event)
-{
- wxClientDC dc(this);
- PrepareDC(dc);
-
- wxPoint pos = event.GetPosition();
-
- m_mouse_worldx = DeviceToLogicalX( pos.x );
- m_mouse_worldy = DeviceToLogicalY( pos.y );
-
- wxString str;
- str.Printf( "Current mouse position: %f,%f", m_mouse_worldx, m_mouse_worldy );
- m_parent->SetStatusText( str );
-
- if (!event.m_controlDown && !GetCaptured())
- {
- if (event.LeftDown())
- {
- m_zoom_x1=m_zoom_x2=pos.x;
- m_zoom_y1=m_zoom_y2=pos.y;
- }
- if (event.RightDown())
- {
- SetMappingScroll(m_virtm_minX,m_virtm_minY,m_virtm_maxX,m_virtm_maxY,0);
- Update( 0,0, GetBufferWidth(), GetBufferHeight(), TRUE );
- UpdateNow();
- }
- if (event.LeftUp())
- {
- m_zoom_x2=pos.x;
- m_zoom_y2=pos.y;
- double x_virt_min=DeviceToLogicalX(m_zoom_x1);
- double y_virt_min=DeviceToLogicalY(m_zoom_y2);
- double x_virt_max=DeviceToLogicalX(m_zoom_x2);
- double y_virt_max=DeviceToLogicalY(m_zoom_y1);
- SetMappingScroll(x_virt_min,y_virt_min,x_virt_max,y_virt_max,0);
- Update( 0,0, GetBufferWidth(), GetBufferHeight(), TRUE );
- UpdateNow();
- }
- if (event.Dragging()&& event.m_leftDown)
- {
- dc.SetLogicalFunction(wxINVERT);
- dc.DrawRectangle(m_zoom_x1,m_zoom_y1,m_zoom_x2-m_zoom_x1,m_zoom_y2-m_zoom_y1 );
- m_zoom_x2=pos.x;
- m_zoom_y2=pos.y;
- dc.DrawRectangle(m_zoom_x1,m_zoom_y1,m_zoom_x2-m_zoom_x1,m_zoom_y2-m_zoom_y1 );
- }
- }
- else
- {
- wxVectorCanvas::OnMouse(event);
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// MyApp
-//-----------------------------------------------------------------------------
-
-// main program
-
-IMPLEMENT_APP(MyApp)
-
-bool MyApp::OnInit()
-{
- m_fontpath = getenv("TRUETYPE");
- m_fontpath = "c:/WINNT/Fonts/times.ttf";
- if ( !m_fontpath )
- {
- wxLogError("Please set env var TRUETYPE to the path where times.ttf lives.");
-
- return FALSE;
-
- }
-
-#if wxUSE_LIBPNG
- wxImage::AddHandler( new wxPNGHandler );
-#endif
-
- wxFrame *frame = new MyFrame((wxFrame *) NULL, "wxCanvas Example", wxPoint(0,0), wxSize(400,500));
- frame->Show( TRUE );
-
- SetTopWindow(frame);
-
- return TRUE;
-}
-
+++ /dev/null
-/*
- * Program: canvas
- *
- * Author: Robert Roebling
- *
- * Copyright: (C) 1998, Robert Roebling
- *
- */
-// For compilers that support precompilation, includes "wx/wx.h".
-
-#ifndef __test_H__
-#define __test_H__
-
-#if defined(__GNUG__) && !defined(__APPLE__)
- #pragma interface "test.cpp"
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/wx.h"
-#endif
-
-#include <wx/image.h>
-#include <wx/file.h>
-#include <wx/timer.h>
-#include <wx/log.h>
-#include <wx/splitter.h>
-
-#include "wx/canvas/canvas.h"
-#include "wx/canvas/polygon.h"
-
-class MyCanvas;
-
-// derived classes
-class MywxCanvasObjectRef: public wxCanvasObjectRef
-{
- DECLARE_DYNAMIC_CLASS(MywxCanvasObjectRef)
-
-public:
- MywxCanvasObjectRef();
- MywxCanvasObjectRef(double x, double y, wxCanvasObjectGroup* group);
- ~MywxCanvasObjectRef();
-
- void OnMouseEvent(wxMouseEvent &event);
-
-private:
- DECLARE_EVENT_TABLE()
-};
-
-
-class MyEventHandler: public wxEvtHandler
-{
-public:
- MyEventHandler();
-
- void OnMouseEvent(wxMouseEvent &event);
-
-private:
-
- DECLARE_EVENT_TABLE()
-};
-
-
-class MySplitterWindow : public wxSplitterWindow
-{
-public:
- MySplitterWindow(wxFrame *parent, wxWindowID id)
- : wxSplitterWindow(parent, id, wxDefaultPosition, wxDefaultSize, wxSP_3D )
- {
- m_frame = parent;
- }
-
- virtual bool OnSashPositionChange(int newSashPosition)
- {
- if ( !wxSplitterWindow::OnSashPositionChange(newSashPosition) )
- return FALSE;
-
- wxString str;
- str.Printf( _T("Sash position = %d"), newSashPosition);
- m_frame->SetStatusText(str);
-
- return TRUE;
- }
-
- void SetStatusText(const wxString& str ){m_frame->SetStatusText(str);}
-
-private:
- wxFrame *m_frame;
-};
-
-
-// MyFrame
-const int ID_ABOUT = 109;
-
-// MyFrame
-class MyFrame: public wxFrame
-{
-public:
- MyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos, const wxSize& size);
- virtual ~MyFrame();
-
- // Menu commands
- void SplitHorizontal(wxCommandEvent& event);
- void SplitVertical(wxCommandEvent& event);
- void Unsplit(wxCommandEvent& event);
- void SetMinSize(wxCommandEvent& event);
- void Quit(wxCommandEvent& event);
-
- // Menu command update functions
- void UpdateUIHorizontal(wxUpdateUIEvent& event);
- void UpdateUIVertical(wxUpdateUIEvent& event);
- void UpdateUIUnsplit(wxUpdateUIEvent& event);
-
- void OnAbout( wxCommandEvent &event );
- void OnNewFrame( wxCommandEvent &event );
- void OnQuit( wxCommandEvent &event );
- void OnTimer( wxTimerEvent &event );
-
- wxCanvasObject *m_sm1;
- wxCanvasObject *m_sm2;
- wxCanvasObject *m_sm3;
- wxCanvasObject *m_sm4;
-
- MywxCanvasObjectRef *m_ref;
- MywxCanvasObjectRef *m_ref2;
-
- wxTimer *m_timer;
- wxTextCtrl *m_log;
-
- wxBitmap gs_bmp36_mono;
-
-private:
-
- void UpdatePosition();
-
- wxMenu* fileMenu;
- wxMenuBar* menuBar;
- MyCanvas* m_canvas1;
- MyCanvas* m_canvas2;
- MySplitterWindow* m_splitter;
-
- wxCanvasAdmin m_canvasadmin;
-
- wxCanvasObjectGroup* m_datatree;
-
- DECLARE_EVENT_TABLE()
-
- MyEventHandler* m_eventhandler;
-};
-
-// ID for the menu commands
-enum
-{
- SPLIT_QUIT,
- SPLIT_HORIZONTAL,
- SPLIT_VERTICAL,
- SPLIT_UNSPLIT,
- SPLIT_SETMINSIZE
-};
-
-// Window ids
-#define SPLITTER_WINDOW 100
-#define SPLITTER_FRAME 101
-#define CANVAS1 102
-#define CANVAS2 103
-
-class MyCanvas: public wxVectorCanvas
-{
-public:
- MyCanvas( wxCanvasAdmin* admin, MySplitterWindow *parent, wxWindowID id = -1,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxScrolledWindowStyle );
-
- void OnMouseEvent(wxMouseEvent& event);
-
-private:
-
- //mouse position used for displaying it in the statusbar
- int m_mouse_x;
- //mouse position used for displaying it in the statusbar
- int m_mouse_y;
- //mouse position used for displaying it in the statusbar
- double m_mouse_worldx;
- //mouse position used for displaying it in the statusbar
- double m_mouse_worldy;
-
- //mouse position used for zooming
- double m_zoom_x1;
- //mouse position used for zooming
- double m_zoom_y1;
- //mouse position used for zooming
- double m_zoom_x2;
- //mouse position used for zooming
- double m_zoom_y2;
-
- //declare events
- DECLARE_EVENT_TABLE()
-
- //parent of the canvas
- MySplitterWindow *m_parent;
-};
-
-// MyApp
-
-class MyApp: public wxApp
-{
-public:
- virtual bool OnInit();
-
- const wxString& GetFontPath() const { return m_fontpath; }
-
-private:
- wxString m_fontpath;
-};
-
-#endif
+++ /dev/null
-#include "wx/msw/wx.rc"
-
-
+++ /dev/null
-# Microsoft Developer Studio Project File - Name="CanvasVC" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=CanvasVC - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "CanvasVC.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "CanvasVC.mak" CFG="CanvasVC - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "CanvasVC - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "CanvasVC - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "CanvasVC - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../include" /I "../../include" /I "../../../lib/msw" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x809
-# ADD RSC /l 0x809
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"..\..\..\lib\canvas.lib"
-
-!ELSEIF "$(CFG)" == "CanvasVC - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "../../../include" /I "../../include" /I "../../../lib/mswd" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x809
-# ADD RSC /l 0x809
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"..\..\..\lib\canvasd.lib"
-
-!ENDIF
-
-# Begin Target
-
-# Name "CanvasVC - Win32 Release"
-# Name "CanvasVC - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\bbox.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\canvas.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\liner.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\polygon.cpp
-# End Source File
-# End Target
-# End Project
+++ /dev/null
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "CanvasVC"=.\CanvasVC.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
+++ /dev/null
-# $Id$
-
-top_srcdir = @top_srcdir@/..
-top_builddir = ../../..
-libsrc_dir = contrib/src/canvas
-
-TARGET_LIBNAME=lib@WX_LIBRARY_BASENAME@_canvas-@WX_RELEASE@
-
-LIBVERSION_CURRENT=@WX_CURRENT@
-LIBVERSION_REVISION=@WX_REVISION@
-LIBVERSION_AGE=@WX_AGE@
-
-
-HEADER_PATH=$(top_srcdir)/contrib/include/wx
-HEADER_SUBDIR=canvas
-
-HEADERS=canvas.h bbox.h liner.h polygon.h
-
-OBJECTS=canvas.o bbox.o liner.o polygon.o
-DEPFILES=$(OBJECTS:.o=.d)
-
-APPEXTRADEFS=-I$(top_srcdir)/contrib/include
-
-include $(top_builddir)/src/makelib.env
-
--include $(DEPFILES)
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: bbox.cpp
-// Author: Klaas Holwerda
-// Created: XX/XX/XX
-// Copyright: 2000 (c) Klaas Holwerda
-// Licence: wxWindows Licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifdef __GNUG__
- #pragma implementation "bbox.cpp"
-#endif
-
-// For compilers that support precompilation, includes "wx/wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/canvas/bbox.h"
-
-wxBoundingBox::wxBoundingBox()
-{
- m_minx = m_miny = m_maxx = m_maxy = 0.0;
- m_validbbox = FALSE;
-}
-
-
-wxBoundingBox::wxBoundingBox(const wxBoundingBox &other)
-{
- m_minx = other.m_minx;
- m_miny = other.m_miny;
- m_maxx = other.m_maxx;
- m_maxy = other.m_maxy;
- m_validbbox= other.m_validbbox;
-}
-
-
-wxBoundingBox::wxBoundingBox(const wxPoint2DDouble& a)
-{
- m_minx = a.m_x;
- m_maxx = a.m_x;
- m_miny = a.m_y;
- m_maxy = a.m_y;
- m_validbbox = TRUE;
-}
-
-wxBoundingBox::wxBoundingBox(double xmin, double ymin, double xmax, double ymax)
-{
- m_minx = xmin;
- m_miny = ymin;
- m_maxx = xmax;
- m_maxy = ymax;
- m_validbbox = TRUE;
-}
-
-// This function checks if two bboxes intersect
-bool wxBoundingBox::And(wxBoundingBox *_bbox, double Marge)
-{
- assert (m_validbbox == TRUE);
- assert (_bbox->GetValid());
- m_minx = wxMax(m_minx, _bbox->m_minx);
- m_maxx = wxMin(m_maxx, _bbox->m_maxx);
- m_miny = wxMax(m_miny, _bbox->m_miny);
- m_maxy = wxMin(m_maxy, _bbox->m_maxy);
- return (bool)
- (
- ((m_minx - Marge) < (m_maxx + Marge)) &&
- ((m_miny - Marge) < (m_maxy + Marge))
- );
-}
-
-// Shrink the boundingbox with the given marge
-void wxBoundingBox::Shrink(const double Marge)
-{
- assert (m_validbbox == TRUE);
-
- m_minx += Marge;
- m_maxx -= Marge;
- m_miny += Marge;
- m_maxy -= Marge;
-}
-
-
-// Expand the boundingbox with another boundingbox
-void wxBoundingBox::Expand(const wxBoundingBox &other)
-{
- if (!m_validbbox)
- {
- *this=other;
- }
- else
- {
- m_minx = wxMin(m_minx, other.m_minx);
- m_maxx = wxMax(m_maxx, other.m_maxx);
- m_miny = wxMin(m_miny, other.m_miny);
- m_maxy = wxMax(m_maxy, other.m_maxy);
- }
-}
-
-
-// Expand the boundingbox with a point
-void wxBoundingBox::Expand(const wxPoint2DDouble& a_point)
-{
- if (!m_validbbox)
- {
- m_minx = m_maxx = a_point.m_x;
- m_miny = m_maxy = a_point.m_y;
- m_validbbox=TRUE;
- }
- else
- {
- m_minx = wxMin(m_minx, a_point.m_x);
- m_maxx = wxMax(m_maxx, a_point.m_x);
- m_miny = wxMin(m_miny, a_point.m_y);
- m_maxy = wxMax(m_maxy, a_point.m_y);
- }
-}
-
-// Expand the boundingbox with a point
-void wxBoundingBox::Expand(double x,double y)
-{
- if (!m_validbbox)
- {
- m_minx = m_maxx = x;
- m_miny = m_maxy = y;
- m_validbbox=TRUE;
- }
- else
- {
- m_minx = wxMin(m_minx, x);
- m_maxx = wxMax(m_maxx, x);
- m_miny = wxMin(m_miny, y);
- m_maxy = wxMax(m_maxy, y);
- }
-}
-
-
-// Expand the boundingbox with two points
-void wxBoundingBox::Expand(const wxPoint2DDouble& a, const wxPoint2DDouble& b)
-{
- Expand(a);
- Expand(b);
-}
-
-// Enlarge the boundingbox with the given marge
-void wxBoundingBox::EnLarge(const double marge)
-{
- if (!m_validbbox)
- {
- m_minx = m_maxx = marge;
- m_miny = m_maxy = marge;
- m_validbbox=TRUE;
- }
- else
- {
- m_minx -= marge;
- m_maxx += marge;
- m_miny -= marge;
- m_maxy += marge;
- }
-}
-
-// Calculates if two boundingboxes intersect. If so, the function returns _ON.
-// If they do not intersect, two scenario's are possible:
-// other is outside this -> return _OUT
-// other is inside this -> return _IN
-OVERLAP wxBoundingBox::Intersect(wxBoundingBox &other, double Marge)
-{
- assert (m_validbbox == TRUE);
-
- // other boundingbox must exist
- assert (&other);
-
- if (((m_minx - Marge) > (other.m_maxx + Marge)) ||
- ((m_maxx + Marge) < (other.m_minx - Marge)) ||
- ((m_maxy + Marge) < (other.m_miny - Marge)) ||
- ((m_miny - Marge) > (other.m_maxy + Marge)))
- return _OUT;
-
- // Check if other.bbox is inside this bbox
- if ((m_minx <= other.m_minx) &&
- (m_maxx >= other.m_maxx) &&
- (m_maxy >= other.m_maxy) &&
- (m_miny <= other.m_miny))
- return _IN;
-
- // Boundingboxes intersect
- return _ON;
-}
-
-
-// Checks if a line intersects the boundingbox
-bool wxBoundingBox::LineIntersect(const wxPoint2DDouble& begin, const wxPoint2DDouble& end )
-{
- assert (m_validbbox == TRUE);
-
- return (bool)
- !(((begin.m_y > m_maxy) && (end.m_y > m_maxy)) ||
- ((begin.m_y < m_miny) && (end.m_y < m_miny)) ||
- ((begin.m_x > m_maxx) && (end.m_x > m_maxx)) ||
- ((begin.m_x < m_minx) && (end.m_x < m_minx)));
-}
-
-
-// Is the given point in the boundingbox ??
-bool wxBoundingBox::PointInBox(double x, double y, double Marge)
-{
- assert (m_validbbox == TRUE);
-
- if ( x >= (m_minx - Marge) && x <= (m_maxx + Marge) &&
- y >= (m_miny - Marge) && y <= (m_maxy + Marge) )
- return TRUE;
- return FALSE;
-}
-
-
-//
-// Is the given point in the boundingbox ??
-//
-bool wxBoundingBox::PointInBox(const wxPoint2DDouble& a, double Marge)
-{
- assert (m_validbbox == TRUE);
-
- return PointInBox(a.m_x, a.m_y, Marge);
-}
-
-
-wxPoint2DDouble wxBoundingBox::GetMin()
-{
- assert (m_validbbox == TRUE);
-
- return wxPoint2DDouble(m_minx, m_miny);
-}
-
-
-wxPoint2DDouble wxBoundingBox::GetMax()
-{
- assert (m_validbbox == TRUE);
-
- return wxPoint2DDouble(m_maxx, m_maxy);
-}
-
-bool wxBoundingBox::GetValid() const
-{
- return m_validbbox;
-}
-
-void wxBoundingBox::SetMin(double px, double py)
-{
- m_minx = px;
- m_miny = py;
- if (!m_validbbox)
- {
- m_maxx = px;
- m_maxy = py;
- m_validbbox = TRUE;
- }
-}
-
-void wxBoundingBox::SetMax(double px, double py)
-{
- m_maxx = px;
- m_maxy = py;
- if (!m_validbbox)
- {
- m_minx = px;
- m_miny = py;
- m_validbbox = TRUE;
- }
-}
-
-void wxBoundingBox::SetValid(bool value)
-{
- m_validbbox = value;
-}
-
-// adds an offset to the boundingbox
-// usage : a_boundingbox.Translate(a_point);
-void wxBoundingBox::Translate(wxPoint2DDouble& offset)
-{
- assert (m_validbbox == TRUE);
-
- m_minx += offset.m_x;
- m_maxx += offset.m_x;
- m_miny += offset.m_y;
- m_maxy += offset.m_y;
-}
-
-
-// clears the bounding box settings
-void wxBoundingBox::Reset()
-{
- m_minx = 0.0;
- m_maxx = 0.0;
- m_miny = 0.0;
- m_maxy = 0.0;
- m_validbbox = FALSE;
-}
-
-
-void wxBoundingBox::SetBoundingBox(const wxPoint2DDouble& a_point)
-{
- m_minx = a_point.m_x;
- m_maxx = a_point.m_x;
- m_miny = a_point.m_y;
- m_maxy = a_point.m_y;
-}
-
-
-// Expands the boundingbox with the given point
-// usage : a_boundingbox = a_boundingbox + pointer_to_an_offset;
-wxBoundingBox& wxBoundingBox::operator+(wxBoundingBox &other)
-{
- assert (m_validbbox == TRUE);
- assert (other.GetValid());
-
- Expand(other);
- return *this;
-}
-
-
-// makes a boundingbox same as the other
-wxBoundingBox& wxBoundingBox::operator=( const wxBoundingBox &other)
-{
- assert (other.GetValid());
-
- m_minx = other.m_minx;
- m_maxx = other.m_maxx;
- m_miny = other.m_miny;
- m_maxy = other.m_maxy;
- m_validbbox = other.m_validbbox;
- return *this;
-}
-
-void wxBoundingBox::MapBbox( const wxTransformMatrix& matrix)
-{
- assert (m_validbbox == TRUE);
-
- double x1,y1,x2,y2,x3,y3,x4,y4;
-
- matrix.TransformPoint( m_minx, m_miny, x1, y1 );
- matrix.TransformPoint( m_minx, m_maxy, x2, y2 );
- matrix.TransformPoint( m_maxx, m_maxy, x3, y3 );
- matrix.TransformPoint( m_maxx, m_miny, x4, y4 );
-
- double xmin = wxMin(x1,x2);
- xmin = wxMin(xmin,x3);
- xmin = wxMin(xmin,x4);
-
- double xmax = wxMax( x1, x2);
- xmax = wxMax(xmax,x3);
- xmax = wxMax(xmax,x4);
-
- double ymin = wxMin(y1, y2);
- ymin = wxMin(ymin,y3);
- ymin = wxMin(ymin,y4);
-
- double ymax = wxMax(y1,y2);
- ymax = wxMax(ymax,y3);
- ymax = wxMax(ymax,y4);
-
- // Use these min and max values to set the new boundingbox
- m_minx = xmin;
- m_miny = ymin;
- m_maxx = xmax;
- m_maxy = ymax;
-}
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: canvas.cpp
-// Author: Robert Roebling
-// Created: XX/XX/XX
-// Copyright: 2000 (c) Robert Roebling
-// Licence: wxWindows Licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifdef __GNUG__
- #pragma implementation "canvas.cpp"
-#endif
-
-// For compilers that support precompilation, includes "wx/wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/canvas/canvas.h"
-#include "wx/canvas/polygon.h"
-#include "wx/canvas/liner.h"
-
-#ifdef __WXGTK__
- #include <gtk/gtk.h>
- #include <gdk/gdkrgb.h>
- #include "wx/gtk/win_gtk.h"
-#endif
-
-#ifndef wxUSE_FREETYPE
- #define wxUSE_FREETYPE 0
-#endif
-
-#if wxUSE_FREETYPE
- #include <freetype/freetype.h>
-#endif
-
-//#define CANVASDEBUG
-
-//----------------------------------------------------------------------------
-// globals
-//----------------------------------------------------------------------------
-
-static const double pi = 3.1415926535;
-
-#if wxUSE_FREETYPE
-FT_Library g_freetypeLibrary;
-#endif
-
-//----------------------------------------------------------------------------
-// wxCanvasObject
-//----------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(wxCanvasObject, wxEvtHandler)
-
-wxCanvasObject::wxCanvasObject()
-{
- // the default event handler is just this object
- m_eventHandler=this;
- m_admin = NULL;
- m_isControl = FALSE;
- m_isVector = FALSE;
- m_isImage = FALSE;
- m_visible = TRUE;
- m_dragmode = wxDRAG_ONTOP;
-// handy when debugging
-// m_dragmode = wxDRAG_RECTANGLE;
- m_dragable = TRUE;
-}
-
-bool wxCanvasObject::ProcessCanvasObjectEvent(wxEvent& event)
-{
- return m_eventHandler->ProcessEvent(event);
-}
-
-void wxCanvasObject::PushEventHandler(wxEvtHandler *handler)
-{
- handler->SetNextHandler(GetEventHandler());
- m_eventHandler=handler;
-}
-
-wxEvtHandler *wxCanvasObject::PopEventHandler(bool deleteHandler)
-{
- wxEvtHandler *handlerA = m_eventHandler;
- if ( handlerA )
- {
- wxEvtHandler *handlerB = handlerA->GetNextHandler();
- handlerA->SetNextHandler((wxEvtHandler *)NULL);
- m_eventHandler=handlerB;
- if ( deleteHandler )
- {
- delete handlerA;
- handlerA = (wxEvtHandler *)NULL;
- }
- }
-
- return handlerA;
-}
-
-void wxCanvasObject::AppendEventHandler(wxEvtHandler *handler)
-{
- GetEventHandler()->SetNextHandler(handler);
-}
-
-wxEvtHandler *wxCanvasObject::RemoveLastEventHandler(bool deleteHandler)
-{
- //always the first in the row
- wxEvtHandler *handlerA = m_eventHandler;
- wxEvtHandler *handlerB=handlerA;
- //goto the end
- while ( handlerA->GetNextHandler() )
- {
- handlerB = handlerA;
- handlerA = handlerA->GetNextHandler();
- }
-
- handlerB->SetNextHandler((wxEvtHandler *)NULL);
- if ( deleteHandler )
- {
- delete handlerA;
- }
-
- return GetEventHandler();
-}
-
-wxRect wxCanvasObject::GetAbsoluteArea(const wxTransformMatrix& cworld)
-{
- wxBoundingBox tmp=m_bbox;
- tmp.MapBbox(cworld);
-
- int x1 = m_admin->LogicalToDeviceX( tmp.GetMinX() );
- int y1 = m_admin->LogicalToDeviceY( tmp.GetMinY() );
- int x2 = m_admin->LogicalToDeviceX( tmp.GetMaxX() );
- int y2 = m_admin->LogicalToDeviceY( tmp.GetMaxY() );
-
- if (x1 > x2)
- {
- int tmp = x1;
- x1 = x2;
- x2 = tmp;
- }
- if (y1 > y2)
- {
- int tmp = y1;
- y1 = y2;
- y2 = tmp;
- }
-
- wxRect tmparea;
- tmparea.x = x1;
- tmparea.y = y1;
- tmparea.width = x2-x1; // FIXME +1 ?
- tmparea.height = y2-y1; // FIXME +1 ?
-
- return tmparea;
-}
-
-void wxCanvasObject::MoveAbsolute( double x, double y )
-{
- //save old position of boundingbox
- double oldx = GetXMin();
- double oldy = GetYMin();
- double w = m_bbox.GetWidth();
- double h = m_bbox.GetHeight();
-
- SetPosXY(x,y);
-
- double newx=GetXMin();
- double newy=GetYMin();
-
- double leftu,rightu,bottomu,topu ;
- leftu = wxMin (oldx, newx ) ;
- rightu = wxMax (oldx + w, newx + w) ;
- topu = wxMin (oldy, newy) ;
- bottomu = wxMax (oldy + h, newy + h) ;
-
- if ( rightu - leftu < 2*w && bottomu - topu < 2*h )
- {
- m_admin->Update( this,leftu, topu, rightu - leftu, bottomu - topu);
- }
- else
- {
- m_admin->Update( this, oldx, oldy, w, h );
- m_admin->Update( this, newx, newy, w, h );
- }
-}
-
-void wxCanvasObject::MoveRelative( double x, double y )
-{
- //save old position of boundingbox
- double oldx = GetXMin();
- double oldy = GetYMin();
- double w = m_bbox.GetWidth();
- double h = m_bbox.GetHeight();
-
- TransLate(x,y);
-
- double newx=GetXMin();
- double newy=GetYMin();
-
- double leftu,rightu,bottomu,topu ;
- leftu = wxMin (oldx, newx ) ;
- rightu = wxMax (oldx + w, newx + w) ;
- topu = wxMin (oldy, newy) ;
- bottomu = wxMax (oldy + h, newy + h) ;
-
- if ( rightu - leftu < 2*w && bottomu - topu < 2*h )
- {
- m_admin->Update( this,leftu, topu, rightu - leftu, bottomu - topu);
- }
- else
- {
- m_admin->Update( this, oldx, oldy, w, h );
- m_admin->Update( this, newx, newy, w, h );
- }
-}
-
-
-void wxCanvasObject::DragStart()
-{
- if (m_dragmode == wxDRAG_RECTANGLE)
- {
- this->SetVisible(FALSE);
- wxTransformMatrix help;
- double x = GetXMin();
- double y = GetYMin();
- double w = m_bbox.GetWidth();
- double h = m_bbox.GetHeight();
- m_admin->Update( this, x, y, w, h );
- m_admin->UpdateNow();
-
- wxRect recold=GetAbsoluteArea(help);
- wxClientDC dc(m_admin->GetActive());
- dc.SetPen(*wxBLACK_PEN);
- dc.SetBrush(*wxTRANSPARENT_BRUSH);
- dc.SetLogicalFunction(wxINVERT);
- dc.DrawRectangle(recold);
- dc.SetBrush(wxNullBrush);
- dc.SetPen(wxNullPen);
- }
- else if (m_dragmode != wxDRAG_REDRAW)
- {
- this->SetVisible(FALSE);
- wxTransformMatrix help;
- double x = GetXMin();
- double y = GetYMin();
- double w = m_bbox.GetWidth();
- double h = m_bbox.GetHeight();
-
- wxRect recnew=GetAbsoluteArea(help);
-
- //redraw in buffer what should be there without this object
- m_admin->Update( this, x, y, w, h );
- m_admin->GetActive()->Freeze();
-
- //save the drawing (without the object itself to a bitmap)
- m_atnewpos = wxBitmap(recnew.width,recnew.height);
- wxMemoryDC dcm;
- dcm.SelectObject(*m_admin->GetActive()->GetBuffer());
- wxMemoryDC tmp;
- tmp.SelectObject(m_atnewpos);
- tmp.Blit(0,0,recnew.width,recnew.height,&dcm,recnew.x,recnew.y,wxCOPY,FALSE);
- tmp.SelectObject(wxNullBitmap);
- dcm.SelectObject(wxNullBitmap);
- }
-}
-
-
-void wxCanvasObject::DragRelative( double x, double y)
-{
- if (m_dragmode == wxDRAG_RECTANGLE)
- {
- wxTransformMatrix help;
-
- wxRect recold=GetAbsoluteArea(help);
-
- TransLate(x,y);
-
- wxRect recnew=GetAbsoluteArea(help);
-
- wxClientDC dc(m_admin->GetActive());
- dc.SetPen(*wxBLACK_PEN);
- dc.SetBrush(*wxTRANSPARENT_BRUSH);
- dc.SetLogicalFunction(wxINVERT);
- dc.DrawRectangle(recold);
- dc.DrawRectangle(recnew);
- dc.SetBrush(wxNullBrush);
- dc.SetPen(wxNullPen);
- }
- else if (m_dragmode != wxDRAG_REDRAW)
- {
- wxClientDC dc(m_admin->GetActive());
- wxMemoryDC tmp;
-
- wxTransformMatrix help;
- wxRect recold=GetAbsoluteArea(help);
-
- //restore what was there (without the object itself)
- wxMemoryDC dcm;
- dcm.SelectObject(*m_admin->GetActive()->GetBuffer());
- tmp.SelectObject(m_atnewpos);
- dcm.Blit(recold.x,recold.y,recold.width,recold.height,&tmp,0,0,wxCOPY,FALSE);
-
- TransLate(x,y);
-
- wxRect recnew=GetAbsoluteArea(help);
-
- //save the contents of the buffer at the new position
- tmp.Blit(0,0,recnew.width,recnew.height,&dcm,recnew.x,recnew.y,wxCOPY,FALSE);
- tmp.SelectObject(wxNullBitmap);
-
- //m_atnewpos = m_admin->GetActive()->GetBuffer()->GetSubBitmap( recnew );
-
- this->SetVisible(TRUE);
- //redraw object into the buffer
- m_admin->GetActive()->SetDC(&dcm);
- Render(&help,recnew.x,recnew.y,recnew.width,recnew.height);
-
- //draw the union or seperate to the canvas
- double leftu,rightu,bottomu,topu ;
- leftu = wxMin (recold.x, recnew.x ) ;
- rightu = wxMax (recold.x + recold.width, recnew.x + recnew.width ) ;
- topu = wxMin (recold.y, recnew.y) ;
- bottomu = wxMax (recold.y + recold.height, recnew.y + recnew.height) ;
-
- if ( rightu - leftu < 2*recold.width && bottomu - topu < 2*recold.height)
- {
- dc.Blit(leftu,topu,rightu - leftu,bottomu - topu,&dcm,leftu,topu,wxCOPY,FALSE);
- }
- else
- {
- //do them seperate
- //first redraw what should be at the old position in the canvas
- dc.Blit(recold.x,recold.y,recold.width,recold.height,&dcm,recold.x,recold.y,wxCOPY,FALSE);
- //blit the new position of the object to the canvas
- dc.Blit(recnew.x,recnew.y,recnew.width,recnew.height,&dcm,recnew.x,recnew.y,wxCOPY,FALSE);
- }
- dcm.SelectObject(wxNullBitmap);
- this->SetVisible(FALSE);
- }
- else
- MoveRelative(x,y);
-}
-
-
-void wxCanvasObject::DragEnd()
-{
- m_atnewpos = wxBitmap(0,0);
- m_admin->GetActive()->Thaw();
- this->SetVisible(TRUE);
- double x = GetXMin();
- double y = GetYMin();
- double w = m_bbox.GetWidth();
- double h = m_bbox.GetHeight();
- m_admin->Update( this, x, y, w, h );
- m_admin->UpdateNow();
-}
-
-wxCanvasObject* wxCanvasObject::IsHitWorld( double x, double y, double margin )
-{
- if ((x >= m_bbox.GetMinX()-margin) &&
- (x <= m_bbox.GetMaxX()+margin) &&
- (y >= m_bbox.GetMinY()-margin) &&
- (y <= m_bbox.GetMaxY()+margin))
- {
- return this;
- }
-
- return (wxCanvasObject*) NULL;
-}
-
-wxCanvasObject* wxCanvasObject::Contains( wxCanvasObject* obj )
-{
- if (obj == this)
- return this;
-
- return (wxCanvasObject*) NULL;
-}
-
-void wxCanvasObject::CaptureMouse()
-{
- m_admin->GetActive()->SetCaptureMouse( this );
-}
-
-void wxCanvasObject::ReleaseMouse()
-{
- m_admin->GetActive()->SetCaptureMouse( NULL );
-}
-
-bool wxCanvasObject::IsCapturedMouse()
-{
- return (m_admin->GetActive()->GetCaptured() == this);
-}
-
-
-void wxCanvasObject::Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height )
-{
-}
-
-void wxCanvasObject::CalcBoundingBox()
-{
-}
-
-void wxCanvasObject::WriteSVG( wxTextOutputStream &stream )
-{
-}
-
-//----------------------------------------------------------------------------
-// wxCanvasObjectGroup
-//----------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(wxCanvasObjectGroup, wxCanvasObject)
-
-wxCanvasObjectGroup::wxCanvasObjectGroup(double x, double y)
-{
- lworld.Translate(x,y);
- //no objects make the bounding box the x,y and take care of it later
- m_bbox.Expand(x,y);
-}
-
-wxCanvasObjectGroup::~wxCanvasObjectGroup()
-{
-}
-
-void wxCanvasObjectGroup::PushEventHandler(wxEvtHandler *handler)
-{
- wxCanvasObject::PushEventHandler(handler);
- wxNode *node = m_objects.First();
- while (node)
- {
- wxCanvasObject *obj = (wxCanvasObject*) node->Data();
-
- obj->PushEventHandler(handler);
-
- node = node->Next();
- }
-}
-
-wxEvtHandler *wxCanvasObjectGroup::PopEventHandler(bool deleteHandler)
-{
- wxNode *node = m_objects.First();
- while (node)
- {
- wxCanvasObject *obj = (wxCanvasObject*) node->Data();
-
- obj->PopEventHandler(deleteHandler);
-
- node = node->Next();
- }
- return wxCanvasObject::PopEventHandler(deleteHandler);
-}
-
-void wxCanvasObjectGroup::AppendEventHandler(wxEvtHandler *handler)
-{
- wxCanvasObject::AppendEventHandler(handler);
- wxNode *node = m_objects.First();
- while (node)
- {
- wxCanvasObject *obj = (wxCanvasObject*) node->Data();
-
- obj->AppendEventHandler(handler);
-
- node = node->Next();
- }
-}
-
-wxEvtHandler *wxCanvasObjectGroup::RemoveLastEventHandler(bool deleteHandler)
-{
- wxNode *node = m_objects.First();
- while (node)
- {
- wxCanvasObject *obj = (wxCanvasObject*) node->Data();
-
- obj->RemoveLastEventHandler(deleteHandler);
-
- node = node->Next();
- }
- return wxCanvasObject::RemoveLastEventHandler(deleteHandler);
-}
-
-void wxCanvasObjectGroup::TransLate( double x, double y )
-{
- lworld.Translate(x,y);
- CalcBoundingBox();
-}
-
-void wxCanvasObjectGroup::SetAdmin(wxCanvasAdmin* admin)
-{
- m_admin=admin;
- wxNode *node = m_objects.First();
- while (node)
- {
- wxCanvasObject *obj = (wxCanvasObject*) node->Data();
-
- obj->SetAdmin(admin);
-
- node = node->Next();
- }
-}
-
-void wxCanvasObjectGroup::DeleteContents( bool flag)
-{
- m_objects.DeleteContents( flag );
- m_bbox.SetValid(FALSE);
- CalcBoundingBox();
-}
-
-void wxCanvasObjectGroup::Prepend( wxCanvasObject* obj )
-{
- m_objects.Insert( obj );
- if (m_objects.First())
- {
- m_bbox.Expand(obj->GetBbox());
- }
- else
- {
- m_bbox.SetValid(FALSE);
- CalcBoundingBox();
- }
-}
-
-void wxCanvasObjectGroup::Append( wxCanvasObject* obj )
-{
- m_objects.Append( obj );
- if (m_objects.First())
- {
- m_bbox.Expand(obj->GetBbox());
- }
- else
- {
- m_bbox.SetValid(FALSE);
- CalcBoundingBox();
- }
-}
-
-void wxCanvasObjectGroup::Insert( size_t before, wxCanvasObject* obj )
-{
- m_objects.Insert( before, obj );
- m_bbox.SetValid(FALSE);
- if (m_objects.First())
- {
- m_bbox.Expand(obj->GetBbox());
- }
- else
- {
- m_bbox.SetValid(FALSE);
- CalcBoundingBox();
- }
-}
-
-void wxCanvasObjectGroup::Remove( wxCanvasObject* obj )
-{
- m_objects.DeleteObject( obj );
- m_bbox.SetValid(FALSE);
- CalcBoundingBox();
-}
-
-void wxCanvasObjectGroup::CalcBoundingBox()
-{
- m_bbox.SetValid(FALSE);
- wxNode *node = m_objects.First();
- while (node)
- {
- wxCanvasObject *obj = (wxCanvasObject*) node->Data();
-
-
- obj->CalcBoundingBox();
- wxBoundingBox tmp;
- tmp=obj->GetBbox();
- tmp.MapBbox(lworld);
-
- m_bbox.Expand( tmp );
- node = node->Next();
- }
-}
-
-void wxCanvasObjectGroup::Render(wxTransformMatrix* cworld, int x, int y, int width, int height )
-{
- if (!m_visible) return;
-
- wxTransformMatrix backup = *cworld;
- *cworld *= lworld;
-
- wxNode *node = m_objects.First();
-
- if (!node) return;
-
-
-#ifdef CANVASDEBUG
- wxRect absarea=GetAbsoluteArea(*cworld);
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetPen(*wxBLACK_PEN);
- dc->SetBrush(*wxTRANSPARENT_BRUSH);
- dc->DrawRectangle( absarea.x , absarea.y , absarea.width , absarea.height );
- dc->SetBrush(wxNullBrush);
- dc->SetPen(wxNullPen);
-#endif
- //TODO the next will only work if all boundingboxes stay up to date (problem when mowing currently
- /*
- if (! ( wxMax(absarea.x, x) < wxMin(absarea.x + absarea.width , x + width ) &&
- wxMax(absarea.y, y) < wxMin(absarea.y + absarea.height , y + height )
- )
- )
- return;
- */
-
- // cycle through all objects
- while (node)
- {
- wxCanvasObject *obj = (wxCanvasObject*) node->Data();
-
- if (!obj->IsControl() && obj->GetVisible())
- {
-
- //get area at the absolute position
- wxRect absareaobject = obj->GetAbsoluteArea(*cworld);
-
- // If we have 10.000 objects, we will go through
- // this 10.000 times for each update, so we have
- // to optimise carefully.
- int clip_x = absareaobject.x;
- int clip_width = absareaobject.width;
- if (clip_x < x)
- {
- clip_width -= x-clip_x;
- clip_x = x;
- }
- if (clip_width > 0)
- {
- if (clip_x + clip_width > x + width)
- clip_width = x+width-clip_x;
-
- if (clip_width > 0)
- {
- int clip_y = absareaobject.y;
- int clip_height = absareaobject.height;
- if (clip_y < y)
- {
- clip_height -= y-clip_y;
- clip_y = y;
- }
- if (clip_height > 0)
- {
- if (clip_y + clip_height > y + height)
- clip_height = y+height-clip_y;
-
- if (clip_height > 0)
- {
- obj->Render(cworld, clip_x, clip_y, clip_width, clip_height );
- }
- }
- }
- }
- }
-
- node = node->Next();
- }
- *cworld = backup;
-}
-
-void wxCanvasObjectGroup::WriteSVG( wxTextOutputStream &stream )
-{
-}
-
-wxCanvasObject* wxCanvasObjectGroup::IsHitWorld( double x, double y, double margin )
-{
- //KKKfirst check if within bbox
- //will only work if they are always uptodate
- //if (!m_bbox.PointInBox(x,y,margin))
- // return (wxCanvasObject*) NULL;
-
- wxTransformMatrix inverse = lworld;
- double xh,yh;
- inverse.Invert();
- inverse.TransformPoint(x,y,xh,yh);
-
- wxCanvasObject *obj=0;
- wxNode *node = m_objects.Last();
- while (node)
- {
- obj=(wxCanvasObject*) node->Data();
-
- if (!obj->IsControl() )
- {
- if (obj->IsHitWorld(xh,yh,margin))
- {
- return obj;
- }
- }
- node = node->Previous();
- }
-
- return (wxCanvasObject*) NULL;
-}
-
-wxCanvasObject* wxCanvasObjectGroup::Contains( wxCanvasObject* obj )
-{
- wxCanvasObject* cobj;
- wxNode *node = m_objects.First();
- while (node)
- {
- cobj=(wxCanvasObject*) node->Data();
-
- if (cobj->Contains(obj))
- {
- return obj;
- }
- node = node->Next();
- }
-
- return (wxCanvasObject*) NULL;
-}
-
-int wxCanvasObjectGroup::IndexOf( wxCanvasObject* obj )
-{
- return m_objects.IndexOf( obj );
-}
-
-//----------------------------------------------------------------------------
-// wxCanvasObjectRef
-//----------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(wxCanvasObjectRef, wxCanvasObject)
-
-wxCanvasObjectRef::wxCanvasObjectRef(double x, double y, wxCanvasObject* obj)
- : wxCanvasObject()
-{
- lworld.Translate(x,y);
- m_obj = obj;
-
- m_bbox.SetValid(FALSE);
- wxBoundingBox tmp;
- tmp=obj->GetBbox();
- tmp.MapBbox(lworld);
- m_bbox.Expand( tmp );
-}
-
-void wxCanvasObjectRef::PushEventHandler(wxEvtHandler *handler)
-{
- wxCanvasObject::PushEventHandler(handler);
- m_obj->PushEventHandler(handler);
-}
-
-wxEvtHandler *wxCanvasObjectRef::PopEventHandler(bool deleteHandler)
-{
- m_obj->PopEventHandler(deleteHandler);
- return wxCanvasObject::PopEventHandler(deleteHandler);
-}
-
-void wxCanvasObjectRef::AppendEventHandler(wxEvtHandler *handler)
-{
- wxCanvasObject::AppendEventHandler(handler);
- m_obj->AppendEventHandler(handler);
-}
-
-wxEvtHandler *wxCanvasObjectRef::RemoveLastEventHandler(bool deleteHandler)
-{
- m_obj->RemoveLastEventHandler(deleteHandler);
- return wxCanvasObject::RemoveLastEventHandler(deleteHandler);
-}
-
-void wxCanvasObjectRef::TransLate( double x, double y )
-{
- lworld.Translate(x,y);
- CalcBoundingBox();
-}
-
-wxCanvasObject* wxCanvasObjectRef::Contains( wxCanvasObject* obj )
-{
- if (obj == this || m_obj->Contains(obj))
- return this;
-
- return (wxCanvasObject*) NULL;
-}
-
-
-void wxCanvasObjectRef::SetRotation(double rotation)
-{
- lworld.SetRotation(rotation);
- CalcBoundingBox();
-}
-
-void wxCanvasObjectRef::SetScale(double scalex,double scaley)
-{
- lworld.Scale(scalex,scaley,lworld.GetValue(2,0),lworld.GetValue(2,1));
- CalcBoundingBox();
-}
-
-void wxCanvasObjectRef::SetAdmin(wxCanvasAdmin* admin)
-{
- m_admin = admin;
- m_obj->SetAdmin(admin);
-}
-
-void wxCanvasObjectRef::CalcBoundingBox()
-{
- m_bbox.SetValid(FALSE);
- m_obj->CalcBoundingBox();
-
- wxBoundingBox tmp;
- tmp=m_obj->GetBbox();
- tmp.MapBbox(lworld);
- m_bbox.Expand( tmp );
-}
-
-void wxCanvasObjectRef::Render(wxTransformMatrix* cworld, int x, int y, int width, int height )
-{
- if (!m_visible) return;
-
- //get the absolute area (without the local matrix included)
- //the boundingbox is relative to the parent.
- wxRect absarea=GetAbsoluteArea(*cworld);
-
- wxTransformMatrix backup = *cworld;
- *cworld *= lworld;
-
-#ifdef CANVASDEBUG
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetPen(*wxBLACK_PEN);
- dc->SetBrush(*wxTRANSPARENT_BRUSH);
- dc->DrawRectangle( absarea.x , absarea.y , absarea.width , absarea.height );
- dc->SetBrush(wxNullBrush);
- dc->SetPen(wxNullPen);
-#endif
-
- int clip_x = absarea.x;
- int clip_width = absarea.width;
- if (clip_x < x)
- {
- clip_width -= x-clip_x;
- clip_x = x;
- }
- if (clip_width > 0)
- {
- if (clip_x + clip_width > x + width)
- clip_width = x+width-clip_x;
-
- if (clip_width > 0)
- {
- int clip_y = absarea.y;
- int clip_height = absarea.height;
- if (clip_y < y)
- {
- clip_height -= y-clip_y;
- clip_y = y;
- }
- if (clip_height > 0)
- {
- if (clip_y + clip_height > y + height)
- clip_height = y+height-clip_y;
-
- if (clip_height > 0)
- m_obj->Render(cworld, clip_x, clip_y, clip_width, clip_height );
- }
- }
- }
-
- *cworld = backup;
-}
-
-void wxCanvasObjectRef::WriteSVG( wxTextOutputStream &stream )
-{
-}
-
-wxCanvasObject* wxCanvasObjectRef::IsHitWorld( double x, double y, double margin )
-{
- //KKKfirst check if within bbox
- //will only work if they are always uptodate
- //if (!m_bbox.PointInBox(x,y,margin))
- // return (wxCanvasObject*) NULL;
-
- wxTransformMatrix inverse = lworld;
- double xh,yh;
- inverse.Invert();
- inverse.TransformPoint(x,y,xh,yh);
-
- if (m_obj->IsHitWorld(xh,yh,margin))
- return this;
-
- return (wxCanvasObject*) NULL;
-}
-
-
-
-//----------------------------------------------------------------------------
-// wxCanvasRect
-//----------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(wxCanvasRect, wxCanvasObject)
-
-wxCanvasRect::wxCanvasRect( double x, double y, double w, double h , double radius )
- : wxCanvasObject()
-{
- m_x = x;
- m_y = y;
- m_width = w;
- m_height = h;
- m_radius = radius;
-
- m_brush = *wxBLACK_BRUSH;
- m_pen = *wxTRANSPARENT_PEN;
- CalcBoundingBox();
-}
-
-void wxCanvasRect::TransLate( double x, double y )
-{
- m_x += x;
- m_y += y;
- CalcBoundingBox();
-}
-
-void wxCanvasRect::CalcBoundingBox()
-{
- m_bbox.SetMin( m_x , m_y);
- m_bbox.SetMax( m_x + m_width ,m_y + m_height );
-
- //include the pen width also
-//KKK m_bbox.EnLarge(m_pen.GetWidth()+m_radius);
- m_bbox.EnLarge(m_pen.GetWidth()/2);
-}
-
-void wxCanvasRect::Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height )
-{
- if (!m_visible) return;
-
- if (cworld->GetRotation())
- {
- wxPoint *cpoints = new wxPoint[4];
- double x;
- double y;
- cworld->TransformPoint( m_x, m_y, x, y );
- cpoints[0].x = m_admin->LogicalToDeviceX(x);
- cpoints[0].y = m_admin->LogicalToDeviceY(y);
- cworld->TransformPoint( m_x , m_y + m_height, x, y );
- cpoints[1].x = m_admin->LogicalToDeviceX(x);
- cpoints[1].y = m_admin->LogicalToDeviceY(y);
- cworld->TransformPoint( m_x + m_width, m_y + m_height, x, y );
- cpoints[2].x = m_admin->LogicalToDeviceX(x);
- cpoints[2].y = m_admin->LogicalToDeviceY(y);
- cworld->TransformPoint( m_x + m_width, m_y , x, y );
- cpoints[3].x = m_admin->LogicalToDeviceX(x);
- cpoints[3].y = m_admin->LogicalToDeviceY(y);
-
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetClippingRegion(clip_x, clip_y, clip_width, clip_height);
- dc->SetBrush(m_brush);
- int pw=m_pen.GetWidth();
- m_pen.SetWidth(m_admin->LogicalToDeviceXRel(pw));
- dc->SetPen(m_pen);
- dc->DrawPolygon(4, cpoints, 0,0,wxWINDING_RULE);
- delete [] cpoints;
- dc->SetBrush(wxNullBrush);
- dc->SetPen(wxNullPen);
- dc->DestroyClippingRegion();
- m_pen.SetWidth(pw);
- }
- else
- {
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetClippingRegion(clip_x, clip_y, clip_width, clip_height);
- dc->SetBrush(m_brush);
- int pw=m_pen.GetWidth();
- m_pen.SetWidth(m_admin->LogicalToDeviceXRel(pw));
- dc->SetPen(m_pen);
- //yes the whole not only the clipping region, because we have a pen also
- int x = m_admin->LogicalToDeviceX(cworld->GetValue(2,0) + m_x );
- int y = m_admin->LogicalToDeviceY(cworld->GetValue(2,1) + m_y );
- int w = m_admin->LogicalToDeviceXRel( m_width );
- int h = m_admin->LogicalToDeviceYRel( m_height );
- int r = m_admin->LogicalToDeviceYRel( m_radius );
- if (w > 0 && w < 1) w=1;
- if (w < 0 && w > -1) w=-1;
- if (h > 0 && h < 1) h=1;
- if (h < 0 && h > -1) h=-1;
- if (m_radius)
- dc->DrawRoundedRectangle( x,y,w,h,r);
- else
- dc->DrawRectangle( x,y,w,h);
- dc->SetBrush(wxNullBrush);
- dc->SetPen(wxNullPen);
- dc->DestroyClippingRegion();
- m_pen.SetWidth(pw);
- }
-}
-
-void wxCanvasRect::WriteSVG( wxTextOutputStream &stream )
-{
-}
-
-//----------------------------------------------------------------------------
-// wxCanvasCircle
-//----------------------------------------------------------------------------
-
-wxCanvasCircle::wxCanvasCircle( double x, double y, double radius )
- : wxCanvasObject()
-{
- m_x = x;
- m_y = y;
- m_radius = radius;
-
- m_brush = *wxBLACK_BRUSH;
- m_pen = *wxTRANSPARENT_PEN;
- CalcBoundingBox();
-}
-
-void wxCanvasCircle::TransLate( double x, double y )
-{
- m_x += x;
- m_y += y;
- CalcBoundingBox();
-}
-
-void wxCanvasCircle::CalcBoundingBox()
-{
- m_bbox.SetMin( m_x-m_radius , m_y-m_radius );
- m_bbox.SetMax( m_x+m_radius , m_y+m_radius );
-
- //include the pen width also
- m_bbox.EnLarge(m_pen.GetWidth()/2);
-}
-
-void wxCanvasCircle::Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height )
-{
- if (!m_visible) return;
-
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetClippingRegion(clip_x, clip_y, clip_width, clip_height);
- dc->SetBrush(m_brush);
- int pw=m_pen.GetWidth();
- m_pen.SetWidth(m_admin->LogicalToDeviceXRel(pw));
- dc->SetPen(m_pen);
- //yes the whole not only the clipping region, because we have a pen also
- //and rotation on a circle is not important so only a shift with cworld
- int x = m_admin->LogicalToDeviceX(cworld->GetValue(2,0) + m_x );
- int y = m_admin->LogicalToDeviceY(cworld->GetValue(2,1) + m_y );
- int radius = m_admin->LogicalToDeviceXRel( m_radius );
- if (radius < 1) radius=1;
- dc->DrawCircle( x,y,radius);
- dc->SetBrush(wxNullBrush);
- dc->SetPen(wxNullPen);
- dc->DestroyClippingRegion();
- m_pen.SetWidth(pw);
-}
-
-void wxCanvasCircle::WriteSVG( wxTextOutputStream &stream )
-{
-}
-
-wxCanvasObject* wxCanvasCircle::IsHitWorld( double x, double y, double margin )
-{
- if ((x >= m_bbox.GetMinX()-margin) &&
- (x <= m_bbox.GetMaxX()+margin) &&
- (y >= m_bbox.GetMinY()-margin) &&
- (y <= m_bbox.GetMaxY()+margin)
- )
- {
- if (m_radius+m_pen.GetWidth()/2+margin > sqrt(pow(m_x-x,2)+pow(m_y-y,2)))
- return this;
- else
- return (wxCanvasObject*) NULL;
- }
- return (wxCanvasObject*) NULL;
-}
-
-//----------------------------------------------------------------------------
-// wxCanvasEllipse
-//----------------------------------------------------------------------------
-
-wxCanvasEllipse::wxCanvasEllipse( double x, double y, double width, double height )
- : wxCanvasObject()
-{
- m_x = x;
- m_y = y;
- m_width = width;
- m_height = height;
-
- m_brush = *wxBLACK_BRUSH;
- m_pen = *wxTRANSPARENT_PEN;
- CalcBoundingBox();
-}
-
-void wxCanvasEllipse::TransLate( double x, double y )
-{
- m_x += x;
- m_y += y;
- CalcBoundingBox();
-}
-
-void wxCanvasEllipse::CalcBoundingBox()
-{
- m_bbox.SetMin( m_x, m_y );
- m_bbox.SetMax( m_x+m_width , m_y+m_height );
-
- //include the pen width also
- m_bbox.EnLarge(m_pen.GetWidth()/2);
-}
-
-void wxCanvasEllipse::Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height )
-{
- if (!m_visible) return;
-
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetClippingRegion(clip_x, clip_y, clip_width, clip_height);
- dc->SetBrush(m_brush);
- int pw=m_pen.GetWidth();
- m_pen.SetWidth(m_admin->LogicalToDeviceXRel(pw));
- dc->SetPen(m_pen);
- int x = m_admin->LogicalToDeviceX(cworld->GetValue(2,0) + m_x );
- int y = m_admin->LogicalToDeviceY(cworld->GetValue(2,1) + m_y );
- int w = m_admin->LogicalToDeviceXRel( m_width );
- int h = m_admin->LogicalToDeviceYRel( m_height );
- if (w > 0 && w < 1) w=1;
- if (w < 0 && w > -1) w=-1;
- if (h > 0 && h < 1) h=1;
- if (h < 0 && h > -1) h=-1;
- dc->DrawEllipse( x,y,w,h);
- dc->SetBrush(wxNullBrush);
- dc->SetPen(wxNullPen);
- dc->DestroyClippingRegion();
- m_pen.SetWidth(pw);
-}
-
-void wxCanvasEllipse::WriteSVG( wxTextOutputStream &stream )
-{
-}
-
-wxCanvasObject* wxCanvasEllipse::IsHitWorld( double x, double y, double margin )
-{
- if ((x >= m_bbox.GetMinX()-margin) &&
- (x <= m_bbox.GetMaxX()+margin) &&
- (y >= m_bbox.GetMinY()-margin) &&
- (y <= m_bbox.GetMaxY()+margin)
- )
- {
- double a=(m_width+m_pen.GetWidth())/2+margin ;
- double b=(m_height+m_pen.GetWidth())/2+margin;
- double c=pow((m_x+m_width/2-x)/a,2)+pow((m_y+m_height/2-y)/b,2);
- if ( 1 > c)
- return this;
- else
- return (wxCanvasObject*) NULL;
- }
- return (wxCanvasObject*) NULL;
-}
-
-//----------------------------------------------------------------------------
-// wxCanvasEllipticArc
-//----------------------------------------------------------------------------
-
-wxCanvasEllipticArc::wxCanvasEllipticArc( double x, double y, double width, double height, double start, double end )
- : wxCanvasObject()
-{
- m_x = x;
- m_y = y;
- m_width = width;
- m_height = height;
- m_start = start;
- m_end = end;
-
- m_brush = *wxBLACK_BRUSH;
- m_pen = *wxTRANSPARENT_PEN;
- CalcBoundingBox();
-}
-
-void wxCanvasEllipticArc::TransLate( double x, double y )
-{
- m_x += x;
- m_y += y;
- CalcBoundingBox();
-}
-
-void wxCanvasEllipticArc::CalcBoundingBox()
-{
- m_bbox.SetMin( m_x, m_y );
- m_bbox.SetMax( m_x+m_width , m_y+m_height );
-
- //include the pen width also
- m_bbox.EnLarge(m_pen.GetWidth()/2);
-}
-
-void wxCanvasEllipticArc::Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height )
-{
- if (!m_visible) return;
-
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetClippingRegion(clip_x, clip_y, clip_width, clip_height);
- dc->SetBrush(m_brush);
- int pw=m_pen.GetWidth();
- m_pen.SetWidth(m_admin->LogicalToDeviceXRel(pw));
- dc->SetPen(m_pen);
- int x = m_admin->LogicalToDeviceX(cworld->GetValue(2,0) + m_x );
- int y = m_admin->LogicalToDeviceY(cworld->GetValue(2,1) + m_y );
- int w = m_admin->LogicalToDeviceXRel( m_width );
- int h = m_admin->LogicalToDeviceYRel( m_height );
- if (w > 0 && w < 1) w=1;
- if (w < 0 && w > -1) w=-1;
- if (h > 0 && h < 1) h=1;
- if (h < 0 && h > -1) h=-1;
- if (m_admin->GetActive()->GetYaxis())
- dc->DrawEllipticArc( x,y,w,h,-m_end,-m_start);
- else
- dc->DrawEllipticArc( x,y,w,h,m_start,m_end);
- dc->SetBrush(wxNullBrush);
- dc->SetPen(wxNullPen);
- dc->DestroyClippingRegion();
- m_pen.SetWidth(pw);
-}
-
-void wxCanvasEllipticArc::WriteSVG( wxTextOutputStream &stream )
-{
-}
-
-wxCanvasObject* wxCanvasEllipticArc::IsHitWorld( double x, double y, double margin )
-{
- if ((x >= m_bbox.GetMinX()-margin) &&
- (x <= m_bbox.GetMaxX()+margin) &&
- (y >= m_bbox.GetMinY()-margin) &&
- (y <= m_bbox.GetMaxY()+margin)
- )
- {
- double a=(m_width+m_pen.GetWidth())/2+margin ;
- double b=(m_height+m_pen.GetWidth())/2+margin;
- double c=pow((m_x+m_width/2-x)/a,2)+pow((m_y+m_height/2-y)/b,2);
- if ( 1 > c)
- return this;
- else
- return (wxCanvasObject*) NULL;
- }
- return (wxCanvasObject*) NULL;
-}
-
-//----------------------------------------------------------------------------
-// wxCanvasLine
-//----------------------------------------------------------------------------
-
-wxCanvasLine::wxCanvasLine( double x1, double y1, double x2, double y2 )
- : wxCanvasObject()
-{
- m_x1 = x1;
- m_y1 = y1;
- m_x2 = x2;
- m_y2 = y2;
-
- m_pen = *wxBLACK_PEN;
- CalcBoundingBox();
-}
-
-void wxCanvasLine::TransLate( double x, double y )
-{
- m_x1 += x;
- m_y1 += y;
- m_x2 += x;
- m_y2 += y;
- CalcBoundingBox();
-}
-
-void wxCanvasLine::CalcBoundingBox()
-{
- m_bbox.SetMin( m_x1 , m_y1);
- m_bbox.SetMax( m_x2 , m_y2);
-
- //include the pen width also
- m_bbox.EnLarge(m_pen.GetWidth()/2);
-}
-
-void wxCanvasLine::Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height )
-{
- if (!m_visible) return;
-
- double x1,y1,x2,y2;
- cworld->TransformPoint( m_x1, m_y1, x1, y1 );
- cworld->TransformPoint( m_x2, m_y2, x2, y2 );
- x1 = m_admin->LogicalToDeviceX( x1 );
- y1 = m_admin->LogicalToDeviceY( y1 );
- x2 = m_admin->LogicalToDeviceX( x2 );
- y2 = m_admin->LogicalToDeviceY( y2 );
-
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetClippingRegion( clip_x, clip_y, clip_width, clip_height );
- int pw=m_pen.GetWidth();
- m_pen.SetWidth(m_admin->LogicalToDeviceXRel(pw));
- dc->SetPen( m_pen );
- dc->DrawLine( x1, y1, x2, y2 );
-
- dc->DestroyClippingRegion();
- m_pen.SetWidth(pw);
-}
-
-void wxCanvasLine::WriteSVG( wxTextOutputStream &stream )
-{
- // no idea
-}
-
-wxCanvasObject* wxCanvasLine::IsHitWorld( double x, double y, double margin )
-{
- if ((x >= m_bbox.GetMinX()-margin) &&
- (x <= m_bbox.GetMaxX()+margin) &&
- (y >= m_bbox.GetMinY()-margin) &&
- (y <= m_bbox.GetMaxY()+margin)
- )
- {
- wxLine line1(m_x1,m_y1,m_x2,m_y2);
- wxPoint2DDouble P=wxPoint2DDouble(x,y);
- double distance;
- if (line1.PointInLine(P,distance,m_pen.GetWidth()/2+margin) == R_IN_AREA)
- return this;
- else
- return (wxCanvasObject*) NULL;
- }
- return (wxCanvasObject*) NULL;
-}
-
-//----------------------------------------------------------------------------
-// wxCanvasImage
-//----------------------------------------------------------------------------
-
-wxCanvasImage::wxCanvasImage( const wxImage &image, double x, double y, double w, double h )
- : wxCanvasObject()
-{
- m_x = x;
- m_y = y;
- m_width = w;
- m_height = h;
-
- m_image = image;
-
- m_orgw = m_image.GetWidth();
- m_orgh = m_image.GetHeight();
-
- m_isImage = TRUE;
- CalcBoundingBox();
-}
-
-void wxCanvasImage::SetPosXY( double x, double y)
-{
- m_x = x;
- m_y = y;
- CalcBoundingBox();
-}
-
-void wxCanvasImage::TransLate( double x, double y )
-{
- m_x += x;
- m_y += y;
- CalcBoundingBox();
-}
-
-void wxCanvasImage::CalcBoundingBox()
-{
- m_bbox.SetMin( m_x, m_y );
- m_bbox.SetMax( m_x + m_width, m_y + m_height );
-}
-
-void wxCanvasImage::Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height )
-{
- if (!m_visible) return;
-
- wxRect tmparea;
-
- tmparea.x = m_admin->LogicalToDeviceXRel( m_bbox.GetMinX());
- tmparea.y = m_admin->LogicalToDeviceYRel( m_bbox.GetMinY());
- tmparea.width = m_admin->LogicalToDeviceXRel( m_bbox.GetWidth() );
- tmparea.height = m_admin->LogicalToDeviceYRel( m_bbox.GetHeight() );
-
- double x;
- double y;
- cworld->TransformPoint( m_x, m_y, x, y );
- x = m_admin->LogicalToDeviceX(x);
- y = m_admin->LogicalToDeviceY(y);
-
-
- // What is this???
- if ( m_orgw*5 < m_admin->LogicalToDeviceXRel( m_bbox.GetWidth() ) ||
- m_orgw/5 > m_admin->LogicalToDeviceXRel( m_bbox.GetWidth() ) ||
- m_orgh*5 < m_admin->LogicalToDeviceYRel( m_bbox.GetHeight() ) ||
- m_orgh/5 > m_admin->LogicalToDeviceYRel( m_bbox.GetHeight() )
- )
- {
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetClippingRegion(clip_x, clip_y, clip_width, clip_height);
- dc->SetBrush(*wxTRANSPARENT_BRUSH);
- dc->SetPen(*wxBLACK_PEN);
- //yes the whole not only the clipping region, because we have a pen also
- int x = m_admin->LogicalToDeviceX(cworld->GetValue(2,0) + m_x );
- int y = m_admin->LogicalToDeviceY(cworld->GetValue(2,1) + m_y );
- int w = m_admin->LogicalToDeviceXRel( m_width );
- int h = m_admin->LogicalToDeviceYRel( m_height );
- if (w < 1) w=1;
- if (h < 1) h=1;
- dc->DrawRectangle( x,y,w,h);
- dc->SetBrush(wxNullBrush);
- dc->SetPen(wxNullPen);
- dc->DestroyClippingRegion();
- return;
- }
-
- wxImage tmp;
- bool is_cashed = FALSE;
-
- if (m_cImage.Ok() && (m_cW == m_bbox.GetWidth()) && (m_cH == m_bbox.GetHeight()))
- {
- // use cached image
- tmp = m_cImage;
- is_cashed = TRUE;
- }
- else
- {
- if ((m_admin->LogicalToDeviceXRel( m_bbox.GetWidth() ) == m_image.GetWidth()) &&
- (m_admin->LogicalToDeviceYRel( m_bbox.GetHeight() ) == m_image.GetHeight()))
- {
- tmp = m_image;
- }
- else
- {
- tmp = m_image.Scale( m_admin->LogicalToDeviceXRel( m_bbox.GetWidth()),
- m_admin->LogicalToDeviceYRel( m_bbox.GetHeight()) );
- }
-
- // create cached image
- m_cImage = tmp;
- m_cW = tmp.GetWidth();
- m_cH = tmp.GetHeight();
- }
-
-// wxPoint centr(m_admin->LogicalToDeviceX(m_x),m_admin->LogicalToDeviceY(m_y));
- wxPoint centr(0,0);
-
- wxBitmap bmp;
-
- if (m_cBitmap.Ok() && is_cashed && (m_cR == cworld->GetRotation()))
- {
- bmp = m_cBitmap;
- }
- else
- {
- if (cworld->GetRotation())
- tmp = tmp.Rotate(-cworld->GetRotation()/180.0 * pi, centr, TRUE, NULL );
-
- bmp = wxBitmap(tmp);
-
- // create cached bitmap
- m_cBitmap = bmp;
- m_cR = cworld->GetRotation();
- }
-
- wxDC *dc = m_admin->GetActive()->GetDC();
-
- wxPoint centr2;
- if (cworld->GetRotation()> 0)
- {
- centr2.x= (int) (x+m_height*sin(-cworld->GetRotation()/180.0 * pi));
- centr2.y= (int) y;
- }
- else
- {
- centr2.x= (int) x;
- centr2.y= (int) (y-m_width*sin(-cworld->GetRotation()/180.0 * pi));
- }
-
- if (cworld->GetRotation() != 0)
- {
- //TODO clipping not right
- dc->DrawBitmap(bmp,centr2,TRUE );
-// dc->DrawPoint(centr2);
-// dc->DrawPoint(x,y);
- }
- else
- {
- dc->SetClippingRegion( clip_x, clip_y, clip_width, clip_height );
- dc->DrawBitmap( bmp, x, y, TRUE );
- dc->DestroyClippingRegion();
- }
-}
-
-void wxCanvasImage::WriteSVG( wxTextOutputStream &stream )
-{
- // no idea
-}
-
-//----------------------------------------------------------------------------
-// wxCanvasCtrl
-//----------------------------------------------------------------------------
-
-wxCanvasControl::wxCanvasControl( wxWindow *control )
- : wxCanvasObject()
-{
- m_isControl = TRUE;
- m_control = control;
- CalcBoundingBox();
-}
-
-double wxCanvasControl::GetPosX()
-{
- int x,y ;
- m_control->GetPosition( &x, &y );
- return m_admin->DeviceToLogicalX(x);
-}
-
-double wxCanvasControl::GetPosY()
-{
- int x,y ;
- m_control->GetPosition( &x, &y );
- return m_admin->DeviceToLogicalY(y);
-}
-
-void wxCanvasControl::SetPosXY( double x, double y)
-{
- int xd = m_admin->LogicalToDeviceX(x);
- int yd = m_admin->LogicalToDeviceY(y);
- m_control->Move(xd,yd);
-}
-
-
-void wxCanvasControl::TransLate( double x, double y )
-{
- int xdo,ydo;
- m_control->GetPosition( &xdo, &ydo );
- int xd = m_admin->LogicalToDeviceX(x)-xdo;
- int yd = m_admin->LogicalToDeviceY(y)-ydo;
- m_control->Move(xd,yd);
- CalcBoundingBox();
-}
-
-wxCanvasControl::~wxCanvasControl()
-{
- m_control->Destroy();
-}
-
-void wxCanvasControl::CalcBoundingBox()
-{
- wxRect tmparea;
-
- m_control->GetSize( &tmparea.width, &tmparea.height );
- m_control->GetPosition( &tmparea.x, &tmparea.y );
-
- m_bbox.SetMin( tmparea.x , tmparea.y);
- m_bbox.SetMax( tmparea.x + tmparea.width , tmparea.y + tmparea.height);
-
-}
-
-void wxCanvasControl::MoveRelative( double x, double y )
-{
- m_control->Move( m_admin->LogicalToDeviceX(x), m_admin->LogicalToDeviceX(y) );
-}
-
-//----------------------------------------------------------------------------
-// wxCanvasText
-//----------------------------------------------------------------------------
-
-class wxFaceData
-{
-public:
-#if wxUSE_FREETYPE
- FT_Face m_face;
-#else
- void *m_dummy;
-#endif
-};
-
-wxCanvasText::wxCanvasText( const wxString &text, double x, double y, const wxString &fontFile, int size )
- : wxCanvasObject()
-{
- m_text = text;
- m_fontFileName = fontFile;
- m_size = size;
-
- m_red = 0;
- m_green = 0;
- m_blue = 0;
-
- m_alpha = NULL;
-
- m_x = x;
- m_y = y;
-
-#if wxUSE_FREETYPE
- wxFaceData *data = new wxFaceData;
- m_faceData = data;
-
- int error = FT_New_Face( g_freetypeLibrary,
- m_fontFileName,
- 0,
- &(data->m_face) );
-
- error = FT_Set_Char_Size( data->m_face,
- 0,
- m_size*64,
- 96, // screen dpi
- 96 );
-#endif
- CalcBoundingBox();
-}
-
-wxCanvasText::~wxCanvasText()
-{
-#if wxUSE_FREETYPE
- wxFaceData *data = (wxFaceData*) m_faceData;
- delete data;
-#endif
-
- if (m_alpha) delete [] m_alpha;
-}
-
-void wxCanvasText::SetRGB( unsigned char red, unsigned char green, unsigned char blue )
-{
- m_red = red;
- m_green = green;
- m_blue = blue;
-}
-
-void wxCanvasText::SetFlag( int flag )
-{
- m_flag = flag;
-}
-
-void wxCanvasText::Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height )
-{
- if (!m_visible) return;
-
- wxRect tmparea;
- tmparea.x = m_admin->LogicalToDeviceX( m_bbox.GetMinX());
- tmparea.y = m_admin->LogicalToDeviceY( m_bbox.GetMinY());
- tmparea.width = m_admin->LogicalToDeviceXRel( m_bbox.GetWidth() );
- tmparea.height = m_admin->LogicalToDeviceYRel( m_bbox.GetHeight() );
-
- m_alpha = new unsigned char[tmparea.width*tmparea.height];
- memset( m_alpha, 0, tmparea.width*tmparea.height );
-
- if (!m_alpha) return;
-
-#if wxUSE_FREETYPE
- FT_Face face = ((wxFaceData*)m_faceData)->m_face;
- FT_GlyphSlot slot = face->glyph;
- int pen_x = 0;
- int pen_y = m_size;
-
- for (int n = 0; n < (int)m_text.Len(); n++)
- {
- FT_UInt index = FT_Get_Char_Index( face, m_text[(unsigned int)n] );
-
- int error = FT_Load_Glyph( face, index, FT_LOAD_DEFAULT );
- if (error) continue;
-
- error = FT_Render_Glyph( face->glyph, ft_render_mode_normal );
- if (error) continue;
-
- FT_Bitmap *bitmap = &slot->bitmap;
- unsigned char* buffer = bitmap->buffer;
- for (int y = 0; y < bitmap->rows; y++)
- for (int x = 0; x < bitmap->width; x++)
- {
- unsigned char alpha = buffer[ y*bitmap->pitch + x ];
- if (alpha == 0) continue;
-
- int xx = pen_x + slot->bitmap_left + x;
- int yy = pen_y - slot->bitmap_top + y;
- m_alpha[ yy * tmparea.width + xx ] = alpha;
- }
-
- pen_x += slot->advance.x >> 6;
- pen_y += slot->advance.y >> 6;
- }
-#endif
-
- wxBitmap *bitmap = m_admin->GetActive()->GetBuffer();
- wxRect sub_rect( clip_x, clip_y, clip_width, clip_height );
- wxBitmap sub_bitmap( bitmap->GetSubBitmap( sub_rect ) );
-
- wxImage image( sub_bitmap.ConvertToImage() );
-
- // local coordinates
- int start_x = clip_x - tmparea.x;
- int end_x = clip_width + start_x;
- int start_y = clip_y - tmparea.y;
- int end_y = clip_height + start_y;
-
- for (int y = start_y; y < end_y; y++)
- for (int x = start_x; x < end_x; x++)
- {
- int alpha = m_alpha[y*tmparea.width + x];
- if (alpha)
- {
- int image_x = x - start_x;
- int image_y = y - start_y;
- if (alpha == 255)
- {
- image.SetRGB( image_x, image_y, m_red, m_green, m_blue );
- continue;
- }
- int red1 = (m_red * alpha) / 255;
- int green1 = (m_green * alpha) / 255;
- int blue1 = (m_blue * alpha) / 255;
-
- alpha = 255-alpha;
- int red2 = image.GetRed( image_x, image_y );
- int green2 = image.GetGreen( image_x, image_y );
- int blue2 = image.GetBlue( image_x, image_y );
- red2 = (red2 * alpha) / 255;
- green2 = (green2 * alpha) / 255;
- blue2 = (blue2 * alpha) / 255;
-
- image.SetRGB( image_x, image_y, red1+red2, green1+green2, blue1+blue2 );
- }
- }
-
- sub_bitmap = wxBitmap(image);
-
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->DrawBitmap( sub_bitmap, clip_x, clip_y );
-}
-
-void wxCanvasText::WriteSVG( wxTextOutputStream &stream )
-{
-}
-
-void wxCanvasText::TransLate( double x, double y )
-{
- m_x += x;
- m_y += y;
- CalcBoundingBox();
-}
-
-void wxCanvasText::CalcBoundingBox()
-{
- if (m_alpha) delete [] m_alpha;
-
- m_bbox.SetMin( m_x , m_y);
- m_bbox.SetMax( m_x + 100 , m_y + m_size + (m_size/2));
-
-
-}
-
-//----------------------------------------------------------------------------
-// wxCanvas
-//----------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(wxCanvas,wxScrolledWindow)
-
-BEGIN_EVENT_TABLE(wxCanvas,wxScrolledWindow)
- EVT_PAINT( wxCanvas::OnPaint )
- EVT_IDLE( wxCanvas::OnIdle )
- EVT_SIZE( wxCanvas::OnSize )
- EVT_MOUSE_EVENTS( wxCanvas::OnMouse )
- EVT_SET_FOCUS( wxCanvas::OnSetFocus )
- EVT_KILL_FOCUS( wxCanvas::OnKillFocus )
- EVT_ERASE_BACKGROUND( wxCanvas::OnEraseBackground )
-END_EVENT_TABLE()
-
-wxCanvas::wxCanvas( wxCanvasAdmin* admin, wxWindow *parent, wxWindowID id,
- const wxPoint &position, const wxSize& size, long style ) :
- wxScrolledWindow( parent, id, position, size, style )
-{
- // These are unused in wxVectorCanvas
- m_bufferX = 0;
- m_bufferY = 0;
-
- m_admin = admin;
- m_admin->Append( this );
-
- m_needUpdate = FALSE;
- m_background = *wxWHITE;
- m_lastMouse = (wxCanvasObject*)NULL;
- m_captureMouse = (wxCanvasObject*)NULL;
- m_frozen = FALSE;
- m_oldDeviceX = 0;
- m_oldDeviceY = 0;
- m_root = (wxCanvasObjectGroup*)NULL;
-}
-
-wxCanvas::~wxCanvas()
-{
- wxNode *node = m_updateRects.First();
- while (node)
- {
- wxRect *rect = (wxRect*) node->Data();
- delete rect;
- m_updateRects.DeleteNode( node );
- node = m_updateRects.First();
- }
-}
-
-double wxCanvas::GetMinX() const
-{
- return 0.0;
-}
-
-double wxCanvas::GetMinY() const
-{
- return 0.0;
-}
-
-double wxCanvas::GetMaxX() const
-{
- int width;
- GetVirtualSize( &width, NULL );
- return width;
-}
-
-double wxCanvas::GetMaxY() const
-{
- int height;
- GetVirtualSize( NULL, &height );
- return height;
-}
-
-void wxCanvas::SetColour( const wxColour& background )
-{
- m_background = background;
- SetBackgroundColour( m_background );
-
- if (m_frozen) return;
-
- wxMemoryDC dc;
- dc.SelectObject( m_buffer );
- dc.SetPen( *wxTRANSPARENT_PEN );
- wxBrush brush( m_background, wxSOLID );
- dc.SetBrush( brush );
- dc.DrawRectangle( 0, 0, m_buffer.GetWidth(), m_buffer.GetHeight() );
- dc.SelectObject( wxNullBitmap );
-}
-
-void wxCanvas::SetCaptureMouse( wxCanvasObject *obj )
-{
- if (obj)
- {
- wxWindow::CaptureMouse();
- m_captureMouse = obj;
- }
- else
- {
- wxWindow::ReleaseMouse();
- m_captureMouse = NULL;
- }
-}
-
-void wxCanvas::Freeze()
-{
- m_frozen = TRUE;
-}
-
-void wxCanvas::Thaw()
-{
- wxNode *node = m_updateRects.First();
- while (node)
- {
- wxRect *rect = (wxRect*) node->Data();
- delete rect;
- m_updateRects.DeleteNode( node );
- node = m_updateRects.First();
- }
-
- m_frozen = FALSE;
-
- if (m_buffer.Ok())
- Update( m_bufferX, m_bufferY, m_buffer.GetWidth(), m_buffer.GetHeight() );
-}
-
-void wxCanvas::Update( int x, int y, int width, int height, bool blit )
-{
- CalcScrolledPosition( 0, 0, &m_oldDeviceX, &m_oldDeviceY );
-
- m_admin->SetActive(this);
-
- if (!m_root) return;
-
- if (m_frozen) return;
-
- // clip to buffer
- if (x < m_bufferX)
- {
- width -= m_bufferX-x;
- x = m_bufferX;
- }
- if (width <= 0) return;
-
- if (y < m_bufferY)
- {
- height -= m_bufferY-y;
- y = m_bufferY;
- }
- if (height <= 0) return;
-
- if (x+width > m_bufferX+m_buffer.GetWidth())
- {
- width = m_bufferX+m_buffer.GetWidth() - x;
- }
- if (width <= 0) return;
-
- if (y+height > m_bufferY+m_buffer.GetHeight())
- {
- height = m_bufferY+m_buffer.GetHeight() - y;
- }
- if (height <= 0) return;
-
- // update is within the buffer
- m_needUpdate = TRUE;
-
- // has to be blitted to screen later
- if (blit)
- {
- m_updateRects.Append(
- (wxObject*) new wxRect( x,y,width,height ) );
- }
-
- wxTransformMatrix cworld;
-
- wxMemoryDC dc;
- dc.SelectObject( m_buffer );
-
- dc.SetPen( *wxTRANSPARENT_PEN );
- wxBrush brush( m_background, wxSOLID );
- dc.SetBrush( brush );
- dc.SetLogicalFunction(wxCOPY);
-
-#if 0
- if (width != m_buffer.GetWidth() && height != m_buffer.GetHeight())
- {
- dc.SetClippingRegion(x,y,width,height);
- dc.DrawRectangle(x-2,y-2,width+4,height+4);
- dc.DestroyClippingRegion();
- }
- else
- {
- dc.Clear();
- dc.DrawRectangle(0,0,m_buffer.GetWidth(),m_buffer.GetHeight());
- }
-#else
- // No idea, what the code up there does.
- dc.DrawRectangle( x-m_bufferX, y-m_bufferY, width, height );
-#endif
-
- dc.SetBrush(wxNullBrush);
- dc.SetPen(wxNullPen);
-
- dc.SetDeviceOrigin( m_oldDeviceX, m_oldDeviceY );
- m_renderDC = &dc;
-
- m_root->Render( &cworld, x, y, width, height );
-
- m_renderDC = NULL;
- dc.SelectObject( wxNullBitmap );
-}
-
-void wxCanvas::BlitBuffer( wxDC &dc )
-{
- wxNode *node = m_updateRects.First();
- while (node)
- {
- wxRect *rect = (wxRect*) node->Data();
-
- wxMemoryDC mdc;
- mdc.SelectObject( m_buffer );
- dc.Blit( rect->x,
- rect->y,
- rect->width,
- rect->height,
- &mdc,
- rect->x - m_bufferX,
- rect->y - m_bufferY );
- mdc.SelectObject( wxNullBitmap );
-
- delete rect;
- m_updateRects.DeleteNode( node );
- node = m_updateRects.First();
- }
-
- m_needUpdate = FALSE;
-}
-
-void wxCanvas::UpdateNow()
-{
- if (m_frozen) return;
-
- if (!m_needUpdate) return;
-
- wxClientDC dc( this );
- PrepareDC( dc );
-
- BlitBuffer( dc );
-}
-
-void wxCanvas::OnSize(wxSizeEvent &event)
-{
- int w,h;
- GetClientSize( &w, &h );
- m_buffer = wxBitmap( w, h );
-
- CalcUnscrolledPosition( 0, 0, &m_bufferX, &m_bufferY );
-
- wxNode *node = m_updateRects.First();
- while (node)
- {
- wxRect *rect = (wxRect*) node->Data();
- delete rect;
- m_updateRects.DeleteNode( node );
- node = m_updateRects.First();
- }
-
- m_frozen = FALSE;
-
- Update( m_bufferX, m_bufferY, m_buffer.GetWidth(), m_buffer.GetHeight(), FALSE );
-
- event.Skip();
-}
-
-void wxCanvas::OnPaint(wxPaintEvent &event)
-{
- wxPaintDC dc(this);
- PrepareDC( dc );
-
- if (!m_buffer.Ok()) return;
-
- if (m_frozen) return;
-
- m_needUpdate = TRUE;
-
- wxRegionIterator it( GetUpdateRegion() );
- while (it)
- {
- int x = it.GetX();
- int y = it.GetY();
-
- int w = it.GetWidth();
- int h = it.GetHeight();
-
- if (x+w > m_buffer.GetWidth())
- w = m_buffer.GetWidth() - x;
- if (y+h > m_buffer.GetHeight())
- h = m_buffer.GetHeight() - y;
-
- if ((w > 0) && (h > 0))
- {
- x += m_bufferX;
- y += m_bufferY;
- m_updateRects.Append( (wxObject*) new wxRect( x, y, w, h ) );
- }
-
- it++;
- }
-
- BlitBuffer( dc );
-}
-
-void wxCanvas::ScrollWindow( int dx, int dy, const wxRect* rect )
-{
- // If any updates are pending, do them now since they will
- // expect the previous m_bufferX and m_bufferY as well as
- // the previous device origin values.
- wxClientDC dc( this );
- dc.SetDeviceOrigin( m_oldDeviceX, m_oldDeviceY );
- BlitBuffer( dc );
-
- // The buffer always starts at the top left corner of the
- // client area. Indeed, it is the client area.
- CalcUnscrolledPosition( 0, 0, &m_bufferX, &m_bufferY );
-
- // Update everything.
- Update( m_bufferX, m_bufferY, m_buffer.GetWidth(), m_buffer.GetHeight(), FALSE );
-
- // Scroll, actually.
- wxWindow::ScrollWindow( dx, dy, rect );
-}
-
-void wxCanvas::OnMouse(wxMouseEvent &event)
-{
- m_admin->SetActive(this);
- if (!m_root)
- {
- event.Skip();
- return;
- }
-
- int x = event.GetX();
- int y = event.GetY();
-
- //to world coordinates to do hit test in world coordinates
- double xw = DeviceToLogicalX( x );
- double yw = DeviceToLogicalY( y );
-
- //make a select margin of 2 pixels, so also zero line thickness will be hit
- double margin = DeviceToLogicalXRel( 2 );
-
- if (event.GetEventType() == wxEVT_MOTION)
- {
- if (m_captureMouse) //no matter what go to this one
- {
- wxMouseEvent child_event( wxEVT_MOTION );
- child_event.SetEventObject(m_captureMouse);
- child_event.m_x = x;
- child_event.m_y = y;
- child_event.m_leftDown = event.m_leftDown;
- child_event.m_rightDown = event.m_rightDown;
- child_event.m_middleDown = event.m_middleDown;
- child_event.m_controlDown = event.m_controlDown;
- child_event.m_shiftDown = event.m_shiftDown;
- child_event.m_altDown = event.m_altDown;
- child_event.m_metaDown = event.m_metaDown;
-
- m_captureMouse->ProcessCanvasObjectEvent( child_event );
- return;
- }
- else
- {
- wxCanvasObject *obj = m_root->IsHitWorld(xw,yw,margin);
-
- if (obj && !obj->IsControl())
- {
- wxMouseEvent child_event( wxEVT_MOTION );
- child_event.SetEventObject( obj );
- child_event.m_x = x;
- child_event.m_y = y;
- child_event.m_leftDown = event.m_leftDown;
- child_event.m_rightDown = event.m_rightDown;
- child_event.m_middleDown = event.m_middleDown;
- child_event.m_controlDown = event.m_controlDown;
- child_event.m_shiftDown = event.m_shiftDown;
- child_event.m_altDown = event.m_altDown;
- child_event.m_metaDown = event.m_metaDown;
-
- if ((obj != m_lastMouse) && (m_lastMouse != NULL))
- {
- child_event.SetEventType( wxEVT_LEAVE_WINDOW );
- child_event.SetEventObject( m_lastMouse );
- child_event.m_x = x;
- child_event.m_y = y;
- m_lastMouse->ProcessCanvasObjectEvent( child_event );
-
- m_lastMouse = obj;
- child_event.SetEventType( wxEVT_ENTER_WINDOW );
- child_event.SetEventObject( m_lastMouse );
- child_event.m_x = x;
- child_event.m_y = y;
- m_lastMouse->ProcessCanvasObjectEvent( child_event );
-
- child_event.SetEventType( wxEVT_MOTION );
- child_event.SetEventObject( obj );
- }
-
- obj->ProcessCanvasObjectEvent( child_event );
- return;
- }
- }
- if (m_lastMouse)
- {
- wxMouseEvent child_event( wxEVT_LEAVE_WINDOW );
- child_event.SetEventObject( m_lastMouse );
- child_event.m_x = x;
- child_event.m_y = y;
- child_event.m_leftDown = event.m_leftDown;
- child_event.m_rightDown = event.m_rightDown;
- child_event.m_middleDown = event.m_middleDown;
- child_event.m_controlDown = event.m_controlDown;
- child_event.m_shiftDown = event.m_shiftDown;
- child_event.m_altDown = event.m_altDown;
- child_event.m_metaDown = event.m_metaDown;
- m_lastMouse->ProcessCanvasObjectEvent( child_event );
-
- m_lastMouse = (wxCanvasObject*) NULL;
- return;
- }
- }
- else
- {
- if (m_captureMouse) //no matter what go to this one
- {
- wxMouseEvent child_event( event.GetEventType() );
- child_event.SetEventObject(m_captureMouse);
- child_event.m_x = x;
- child_event.m_y = y;
- child_event.m_leftDown = event.m_leftDown;
- child_event.m_rightDown = event.m_rightDown;
- child_event.m_middleDown = event.m_middleDown;
- child_event.m_controlDown = event.m_controlDown;
- child_event.m_shiftDown = event.m_shiftDown;
- child_event.m_altDown = event.m_altDown;
- child_event.m_metaDown = event.m_metaDown;
- m_captureMouse->ProcessCanvasObjectEvent( child_event );
- }
- else
- {
- wxCanvasObject *obj = m_root->IsHitWorld(xw,yw,margin);
-
- if (obj && !obj->IsControl())
- {
- wxMouseEvent child_event( event.GetEventType() );
- child_event.SetEventObject( obj );
- child_event.m_x = x;
- child_event.m_y = y;
- child_event.m_leftDown = event.m_leftDown;
- child_event.m_rightDown = event.m_rightDown;
- child_event.m_middleDown = event.m_middleDown;
- child_event.m_controlDown = event.m_controlDown;
- child_event.m_shiftDown = event.m_shiftDown;
- child_event.m_altDown = event.m_altDown;
- child_event.m_metaDown = event.m_metaDown;
-
- obj->ProcessCanvasObjectEvent( child_event );
- return;
- }
- }
- }
-
- event.Skip();
-}
-
-void wxCanvas::OnIdle(wxIdleEvent &event)
-{
- m_admin->SetActive(this);
- UpdateNow();
- event.Skip();
-}
-
-void wxCanvas::OnSetFocus(wxFocusEvent &event)
-{
- m_admin->SetActive(this);
-}
-
-void wxCanvas::OnKillFocus(wxFocusEvent &event)
-{
-}
-
-
-void wxCanvas::OnEraseBackground(wxEraseEvent &event)
-{
-}
-
-// coordinates conversions
-// -----------------------
-double wxCanvas::DeviceToLogicalX(int x) const
-{
- return (double)(x);
-}
-
-double wxCanvas::DeviceToLogicalY(int y) const
-{
- return (double)(y);
-}
-
-double wxCanvas::DeviceToLogicalXRel(int x) const
-{
- return (double)x;
-}
-
-double wxCanvas::DeviceToLogicalYRel(int y) const
-{
- return (double)y;
-}
-
-int wxCanvas::LogicalToDeviceX(double x) const
-{
- return (int)(x + 0.5);
-}
-
-int wxCanvas::LogicalToDeviceY(double y) const
-{
- return (int)(y + 0.5);
-}
-
-int wxCanvas::LogicalToDeviceXRel(double x) const
-{
- return (int)(x + 0.5);
-}
-
-int wxCanvas::LogicalToDeviceYRel(double y) const
-{
- return (int)(y + 0.5);
-}
-
-//----------------------------------------------------------------------------
-// wxVectorCanvas
-//----------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(wxVectorCanvas,wxCanvas)
-
-BEGIN_EVENT_TABLE(wxVectorCanvas,wxCanvas)
- EVT_SCROLLWIN( wxVectorCanvas::OnScroll )
- EVT_CHAR( wxVectorCanvas::OnChar )
- EVT_SIZE( wxVectorCanvas::OnSize )
-END_EVENT_TABLE()
-
-wxVectorCanvas::wxVectorCanvas( wxCanvasAdmin* admin, wxWindow *parent, wxWindowID id,
- const wxPoint &position, const wxSize& size, long style ) :
- wxCanvas( admin, parent, id, position, size, style )
-{
- m_scrolled = FALSE;
- m_yaxis = FALSE;
-}
-
-double wxVectorCanvas::GetMinX() const
-{
- return m_virt_minX;
-}
-
-double wxVectorCanvas::GetMinY() const
-{
- return m_virt_minY;
-}
-
-double wxVectorCanvas::GetMaxX() const
-{
- return m_virt_maxX;
-}
-
-double wxVectorCanvas::GetMaxY() const
-{
- return m_virt_maxY;
-}
-
-void wxVectorCanvas::ScrollWindow( int dx, int dy, const wxRect* rect )
-{
- // If any updates are pending, do them now since they will
- // expect the previous m_bufferX and m_bufferY as well as
- // the previous device origin values.
- wxClientDC dc( this );
- dc.SetDeviceOrigin( m_oldDeviceX, m_oldDeviceY );
- BlitBuffer( dc );
-
- if (dy != 0)
- {
- double dyv=DeviceToLogicalYRel(dy);
- m_virt_minY=m_virt_minY-dyv;
- m_virt_maxY=m_virt_maxY-dyv;
- }
- if (dx != 0)
- {
- double dxv=DeviceToLogicalXRel(dx);
- m_virt_minX=m_virt_minX-dxv;
- m_virt_maxX=m_virt_maxX-dxv;
- }
-
- m_admin->SetActive(this);
- SetMappingScroll(m_virt_minX,m_virt_minY,m_virt_maxX,m_virt_maxY,FALSE);
-
-
- if (dy != 0)
- {
- if (dy > 0 && dy < m_buffer.GetHeight())
- {
- wxRect rect( 0, 0, m_buffer.GetWidth(), m_buffer.GetHeight()-dy);
- wxBitmap sub_bitmap( m_buffer.GetSubBitmap( rect ) );
- wxMemoryDC dcm;
- dcm.SelectObject( m_buffer );
- dcm.DrawBitmap( sub_bitmap, 0, dy, TRUE );
- dcm.SelectObject( wxNullBitmap );
-
- Update( 0, 0, m_buffer.GetWidth(), dy, TRUE );
- }
- else if (dy < 0 && dy > -m_buffer.GetHeight())
- {
- wxRect rect( 0, -dy, m_buffer.GetWidth(), m_buffer.GetHeight()+dy);
- wxBitmap sub_bitmap( m_buffer.GetSubBitmap( rect ) );
- wxMemoryDC dcm;
- dcm.SelectObject( m_buffer );
- dcm.DrawBitmap( sub_bitmap, 0, 0, TRUE );
- dcm.SelectObject( wxNullBitmap );
-
- Update( 0, m_buffer.GetHeight()+dy, m_buffer.GetWidth(), m_buffer.GetHeight(), TRUE );
- }
- else
- Update( 0, 0, m_buffer.GetWidth(), m_buffer.GetHeight(), TRUE );
- }
-
- if (dx != 0)
- {
- if (dx > 0 && dx < m_buffer.GetWidth())
- {
- wxRect rect( 0, 0, m_buffer.GetWidth()-dx, m_buffer.GetHeight());
- wxBitmap sub_bitmap( m_buffer.GetSubBitmap( rect ) );
- wxMemoryDC dcm;
- dcm.SelectObject( m_buffer );
- dcm.DrawBitmap( sub_bitmap, dx, 0, TRUE );
- dcm.SelectObject( wxNullBitmap );
-
- Update( 0, 0, dx, m_buffer.GetHeight(), TRUE );
- }
- else if (dx < 0 && dx > -m_buffer.GetWidth())
- {
- wxRect rect( -dx, 0, m_buffer.GetWidth()+dx, m_buffer.GetHeight());
- wxBitmap sub_bitmap( m_buffer.GetSubBitmap( rect ) );
- wxMemoryDC dcm;
- dcm.SelectObject( m_buffer );
- dcm.DrawBitmap( sub_bitmap, 0, 0, TRUE );
- dcm.SelectObject( wxNullBitmap );
-
- Update( m_buffer.GetWidth()+dx, 0, m_buffer.GetWidth(), m_buffer.GetHeight(), TRUE );
- }
- else
- Update( 0,0, m_buffer.GetWidth(), m_buffer.GetHeight(), TRUE );
- }
-
- wxWindow::ScrollWindow( dx, dy, rect );
-
- //must be done now because quick repeated scrolling will prevent wxPaint
- //from doing it properly
- UpdateNow();
-}
-
-void wxVectorCanvas::OnSize(wxSizeEvent &event)
-{
- int w,h;
-
- GetClientSize( &w, &h );
-
- wxMemoryDC dc;
- m_buffer = wxBitmap( w, h );
- dc.SelectObject( m_buffer );
- dc.SetPen( *wxTRANSPARENT_PEN );
- wxBrush brush( m_background , wxSOLID );
- dc.SetBrush( brush );
- dc.DrawRectangle( 0, 0, m_buffer.GetWidth(), m_buffer.GetHeight() );
- dc.SelectObject( wxNullBitmap );
-
- wxNode *node = m_updateRects.First();
- while (node)
- {
- wxRect *rect = (wxRect*) node->Data();
- delete rect;
- m_updateRects.DeleteNode( node );
- node = m_updateRects.First();
- }
-
- m_frozen = FALSE;
-
- m_admin->SetActive(this);
- SetMappingScroll(m_virt_minX,m_virt_minY,m_virt_maxX,m_virt_maxY,FALSE);
-
- Update( 0,0, m_buffer.GetWidth(), m_buffer.GetHeight(), FALSE );
-
-// event.Skip();
-}
-
-// maps the virtual window (Real drawing to the window coordinates
-// also used for zooming
-void wxVectorCanvas::SetMappingScroll( double vx1, double vy1, double vx2, double vy2, bool border)
-{
- int dwxi,dwyi;
- GetClientSize(&dwxi,&dwyi);
-
- if (vx2==vx1) vx2=vx1+100000;
- if (vy2==vy1) vy2=vy1+100000;
- m_virt_minX=vx1;
- m_virt_minY=vy1;
- m_virt_maxX=vx2;
- m_virt_maxY=vy2;
-
- double dwx=dwxi;
- double dwy=dwyi;
- if (dwx==0) dwx=1;
- if (dwy==0) dwy=1;
-
- double dvx = m_virt_maxX - m_virt_minX;
- double dvy = m_virt_maxY - m_virt_minY;
-
- // calculate the scaling factor for the virtual window
- double temp_x=0;
- double temp_y=0;
- if ((dvy / dvx) < (dwy / dwx))
- {
- dvy = dvx * (dwy / dwx);
- // calculate the change in the coordinates
- temp_y = (dvy - (m_virt_maxY - m_virt_minY) )/ 2.0;
- }
- else
- {
- dvx = dvy * (dwx / dwy);
- // calculate the change in the coordinates
- temp_x = (dvx - (m_virt_maxX - m_virt_minX) )/ 2.0;
- }
-
- // add or substract the change from the original coordinates
- m_virt_minX=m_virt_minX-temp_x;
- m_virt_minY=m_virt_minY-temp_y;
-
- m_virt_maxX=m_virt_maxX+temp_x;
- m_virt_maxY=m_virt_maxY+temp_y;
-
- // initialize the mapping_matrix used for mapping the
- // virtual windows to the drawing window
-
- // make mappingmatrix
- m_mapping_matrix.Identity();
- if (!border)
- {
- // translate the drawing to 0,0
- if (m_yaxis)
- m_mapping_matrix.Translate(-m_virt_minX,-m_virt_maxY);
- else
- m_mapping_matrix.Translate(-m_virt_minX,-m_virt_minY);
- }
- else
- {
- // make a small white border around the drawing
- m_virt_minX=m_virt_minX- 0.05 * dvx;
- m_virt_minY=m_virt_minY- 0.05 * dvy;
-
- m_virt_maxX=m_virt_maxX+ 0.05 * dvx;
- m_virt_maxY=m_virt_maxY+ 0.05 * dvy;
-
- // translate the drawing to 0,0
- if (m_yaxis)
- m_mapping_matrix.Translate(-m_virt_minX,-m_virt_maxY);
- else
- m_mapping_matrix.Translate(-m_virt_minX,-m_virt_minY);
- }
-
- double scalefactor_x = dwx;
- scalefactor_x /= (m_virt_maxX - m_virt_minX);
-
- double scalefactor_y = dwy;
- scalefactor_y /= (m_virt_maxY - m_virt_minY);
-
- // scale the drawing so it fit's in the window
- m_mapping_matrix.Scale(scalefactor_x, scalefactor_y, 0, 0);
-
- // because of coordinate change mirror over X
- // 0,0 in graphic computerscreens: upperleft corner
- // 0,0 in cartesian: lowerleft corner
- if (m_yaxis)
- {
- m_mapping_matrix.Mirror();
- }
- // make inverse of mapping matrix
- // this is to set coordinates in the statusbar
- // and the calculate screencoordinates to world coordinates used
- // in zooming
- m_inverse_mapping=m_mapping_matrix;
- m_inverse_mapping.Invert();
-
- if (m_scrolled)
- SetScroll(m_virtm_minX,m_virtm_minY,m_virtm_maxX,m_virtm_maxY);
-
- int dx2,dy2;
- GetClientSize(&dx2,&dy2);
- if ( dwxi != dx2 || dwyi != dy2) //scrollbar is/became empty
- SetScroll(m_virtm_minX,m_virtm_minY,m_virtm_maxX,m_virtm_maxY);
-}
-
-
-void wxVectorCanvas::SetScroll(double vx1,double vy1,double vx2,double vy2)
-{
- m_virtm_minX=vx1;
- m_virtm_minY=vy1;
- m_virtm_maxX=vx2;
- m_virtm_maxY=vy2;
-
- double dvx = m_virt_maxX - m_virt_minX;
- double dvy = m_virt_maxY - m_virt_minY;
- double dmvx = m_virtm_maxX - m_virtm_minX;
- double dmvy = m_virtm_maxY - m_virtm_minY;
-
- SetScrollbar(wxHORIZONTAL,(m_virt_minX-m_virtm_minX)/dmvx *1000,dvx/dmvx *1000,1000,FALSE);
- if (m_yaxis)
- {
- SetScrollbar(wxVERTICAL,(m_virtm_maxY-m_virt_maxY)/dmvy *1000,dvy/dmvy *1000,1000,FALSE);
- }
- else
- {
- SetScrollbar(wxVERTICAL,(m_virt_minY-m_virtm_minY)/dmvy *1000,dvy/dmvy *1000,1000,FALSE);
- }
-
- m_scrolled=TRUE;
-}
-
-// coordinates conversions
-// -----------------------
-double wxVectorCanvas::DeviceToLogicalX(int x) const
-{
- return m_inverse_mapping.GetValue(0,0) * x + m_inverse_mapping.GetValue(2,0);
-}
-
-double wxVectorCanvas::DeviceToLogicalY(int y) const
-{
- return m_inverse_mapping.GetValue(1,1) * y + m_inverse_mapping.GetValue(2,1);
-}
-
-double wxVectorCanvas::DeviceToLogicalXRel(int x) const
-{
- return x*m_inverse_mapping.GetValue(0,0);
-}
-
-double wxVectorCanvas::DeviceToLogicalYRel(int y) const
-{
- return y*m_inverse_mapping.GetValue(1,1);
-}
-
-int wxVectorCanvas::LogicalToDeviceX(double x) const
-{
- return (int) (m_mapping_matrix.GetValue(0,0) * x + m_mapping_matrix.GetValue(2,0) + 0.5);
-}
-
-int wxVectorCanvas::LogicalToDeviceY(double y) const
-{
- return (int) (m_mapping_matrix.GetValue(1,1) * y + m_mapping_matrix.GetValue(2,1) + 0.5);
-}
-
-int wxVectorCanvas::LogicalToDeviceXRel(double x) const
-{
- return (int) (x*m_mapping_matrix.GetValue(0,0) + 0.5);
-}
-
-int wxVectorCanvas::LogicalToDeviceYRel(double y) const
-{
- return (int) (y*m_mapping_matrix.GetValue(1,1) + 0.5);
-}
-
-
-// return the inverse mapping matrix for zooming or coordinates
-wxTransformMatrix wxVectorCanvas::GetInverseMappingMatrix()
-{
- return m_inverse_mapping;
-}
-
-wxTransformMatrix wxVectorCanvas::GetMappingMatrix()
-{
- return m_mapping_matrix;
-}
-
-
-// ----------------------------------------------------------------------------
-// scrolling behaviour
-// ----------------------------------------------------------------------------
-
-void wxVectorCanvas::OnScroll(wxScrollWinEvent& event)
-{
- if (event.GetEventType()==wxEVT_SCROLLWIN_THUMBRELEASE)
- {
- if (event.GetOrientation()==wxHORIZONTAL)
- {
- double x=m_virtm_minX+event.GetPosition()/1000.0*(m_virtm_maxX-m_virtm_minX);
- x=LogicalToDeviceXRel(x-m_virt_minX);
- ScrollWindow(-x, 0, (const wxRect *) NULL);
- }
- else
- {
- double y=m_virtm_minY+event.GetPosition()/1000.0*(m_virtm_maxY-m_virtm_minY);
- y=LogicalToDeviceYRel(y-m_virt_minY);
- ScrollWindow(0, -y, (const wxRect *) NULL);
- }
- }
- else if (event.GetEventType()==wxEVT_SCROLLWIN_PAGEUP)
- {
- if (event.GetOrientation()==wxHORIZONTAL)
- {
- double x=GetBufferWidth();
- ScrollWindow(x, 0, (const wxRect *) NULL);
- }
- else
- {
- double y=GetBufferHeight();
- ScrollWindow(0, y, (const wxRect *) NULL);
- }
- }
- else if (event.GetEventType()==wxEVT_SCROLLWIN_PAGEDOWN)
- {
- if (event.GetOrientation()==wxHORIZONTAL)
- {
- double x=-GetBufferWidth();
- ScrollWindow(x, 0, (const wxRect *) NULL);
- }
- else
- {
- double y=-GetBufferHeight();
- ScrollWindow(0, y, (const wxRect *) NULL);
- }
- }
- else if (event.GetEventType()==wxEVT_SCROLLWIN_LINEUP)
- {
- if (event.GetOrientation()==wxHORIZONTAL)
- {
- int x=GetBufferWidth()/10;
- ScrollWindow(x, 0, (const wxRect *) NULL);
- }
- else
- {
- int y=GetBufferHeight()/10;
- ScrollWindow(0, y, (const wxRect *) NULL);
- }
- }
- else if (event.GetEventType()==wxEVT_SCROLLWIN_LINEDOWN)
- {
- if (event.GetOrientation()==wxHORIZONTAL)
- {
- int x=-GetBufferWidth()/10;
- ScrollWindow(x, 0, (const wxRect *) NULL);
- }
- else
- {
- int y=-GetBufferHeight()/10;
- ScrollWindow(0, y, (const wxRect *) NULL);
- }
- }
-
-}
-
-void wxVectorCanvas::OnChar(wxKeyEvent& event)
-{
- switch ( event.KeyCode() )
- {
- case WXK_PAGEUP:
- case WXK_PRIOR:
- {
- double y=GetBufferHeight();
- ScrollWindow(0, y, (const wxRect *) NULL);
- }
- break;
- case WXK_PAGEDOWN:
- case WXK_NEXT:
- {
- double y=-GetBufferHeight();
- ScrollWindow(0, y, (const wxRect *) NULL);
- }
- break;
- case WXK_HOME:
- {
- double y=m_virtm_minY;
- y=LogicalToDeviceYRel(y-m_virt_minY);
- ScrollWindow(0, -y, (const wxRect *) NULL);
- }
- break;
- case WXK_END:
- {
- double y=m_virtm_minY+(m_virtm_maxY-m_virtm_minY);
- y=LogicalToDeviceYRel(y-m_virt_minY);
- ScrollWindow(0, -y, (const wxRect *) NULL);
- }
- break;
- case WXK_UP:
- {
- int y;
- if (!event.ControlDown())
- y=GetBufferHeight()/10;
- else
- y=GetBufferHeight();
- ScrollWindow(0, y, (const wxRect *) NULL);
- }
- break;
-
- case WXK_DOWN:
- {
- int y;
- if (!event.ControlDown())
- y=-GetBufferHeight()/10;
- else
- y=-GetBufferHeight();
- ScrollWindow(0, y, (const wxRect *) NULL);
- }
- break;
-
- case WXK_LEFT:
- {
- int x;
- if (!event.ControlDown())
- x=GetBufferWidth()/10;
- else
- x=GetBufferWidth();
- ScrollWindow(x, 0, (const wxRect *) NULL);
- }
- break;
- case WXK_RIGHT:
- {
- int x;
- if (!event.ControlDown())
- x=-GetBufferWidth()/10;
- else
- x=-GetBufferWidth();
- ScrollWindow(x, 0, (const wxRect *) NULL);
- }
- break;
- default:
- // not for us
- event.Skip();
- }
-}
-
-
-//----------------------------------------------------------------------------
-// wxCanvasAdmin
-//----------------------------------------------------------------------------
-
-wxCanvasAdmin::wxCanvasAdmin()
-{
-
-}
-
-wxCanvasAdmin::~wxCanvasAdmin()
-{
-}
-
-
-void wxCanvasAdmin::Append( wxCanvas* canvas )
-{
- m_canvaslist.Append( canvas );
-}
-
-void wxCanvasAdmin::Remove( wxCanvas* canvas )
-{
- m_canvaslist.DeleteObject( canvas );
-}
-
-void wxCanvasAdmin::Update(wxCanvasObject* obj, double x, double y, double width, double height)
-{
- wxNode *node = m_canvaslist.First();
- while (node)
- {
-
- wxCanvas *canvas = (wxCanvas*) node->Data();
-
- if (m_active == canvas)
- {
- int xi = canvas->LogicalToDeviceX( x);
- int yi = canvas->LogicalToDeviceY( y);
- int wi = canvas->LogicalToDeviceXRel( width );
- int hi = canvas->LogicalToDeviceYRel( height);
- //update a little more then is strictly needed,
- //to get rid of the 1 bit bugs
- if (canvas->GetYaxis())
- canvas->Update( xi-2, yi+hi-2, wi+4, -hi+4);
- else
- canvas->Update( xi-2, yi-2, wi+4, hi+4);
- }
- else
- { wxCanvasObject* topobj=canvas->GetRoot()->Contains(obj);
- if (topobj)
- {
- wxCanvas* tcanvas = m_active;
- SetActive(canvas);
-
- /*
- //KKK TODO somehow the next does not work for update i do not know why
- canvas->GetRoot()->CalcBoundingBox();
- int xi = topobj->GetX();
- int yi = topobj->GetY();
- int wi = topobj->GetWidth();
- int hi = topobj->GetHeight();
- */
- canvas->Update( 0,0, canvas->GetBufferWidth(),canvas->GetBufferHeight());
- SetActive(tcanvas);
- }
- }
-
- node = node->Next();
- }
-}
-
-void wxCanvasAdmin::UpdateNow()
-{
- wxNode *node = m_canvaslist.First();
- while (node)
- {
- wxCanvas *canvas = (wxCanvas*) node->Data();
-
- canvas->UpdateNow();
- node = node->Next();
- }
-}
-
-// coordinates conversions
-// -----------------------
-double wxCanvasAdmin::DeviceToLogicalX(int x) const
-{
- return m_active->DeviceToLogicalX(x);
-}
-
-double wxCanvasAdmin::DeviceToLogicalY(int y) const
-{
- return m_active->DeviceToLogicalY(y);
-}
-
-double wxCanvasAdmin::DeviceToLogicalXRel(int x) const
-{
- return m_active->DeviceToLogicalXRel(x);
-}
-
-double wxCanvasAdmin::DeviceToLogicalYRel(int y) const
-{
- return m_active->DeviceToLogicalYRel(y);
-}
-
-int wxCanvasAdmin::LogicalToDeviceX(double x) const
-{
- return m_active->LogicalToDeviceX(x);
-}
-
-int wxCanvasAdmin::LogicalToDeviceY(double y) const
-{
- return m_active->LogicalToDeviceY(y);
-}
-
-int wxCanvasAdmin::LogicalToDeviceXRel(double x) const
-{
- return m_active->LogicalToDeviceXRel(x);
-}
-
-int wxCanvasAdmin::LogicalToDeviceYRel(double y) const
-{
- return m_active->LogicalToDeviceYRel(y);
-}
-
-void wxCanvasAdmin::SetActive(wxCanvas* activate)
-{
- wxNode *node = m_canvaslist.First();
- while (node)
- {
- wxCanvas *canvas = (wxCanvas*) node->Data();
-
- if (activate == canvas)
- {
- m_active=canvas;
- break;
- }
- node = node->Next();
- }
-}
-//--------------------------------------------------------------------
-// wxCanvasModule
-//--------------------------------------------------------------------
-
-class wxCanvasModule : public wxModule
-{
-public:
- virtual bool OnInit();
- virtual void OnExit();
-
-private:
- DECLARE_DYNAMIC_CLASS(wxCanvasModule)
-};
-
-IMPLEMENT_DYNAMIC_CLASS(wxCanvasModule, wxModule)
-
-bool wxCanvasModule::OnInit()
-{
-#if wxUSE_FREETYPE
- int error = FT_Init_FreeType( &g_freetypeLibrary );
- if (error) return FALSE;
-#endif
-
- return TRUE;
-}
-
-void wxCanvasModule::OnExit()
-{
-#if wxUSE_FREETYPE
- FT_Done_FreeType( g_freetypeLibrary );
-#endif
-}
-
-
-
-
+++ /dev/null
-/*
-Program wxLine.CPP
-Purpose Mainly used for calculating crossings
-Last Update 05-12-1995
-*/
-
-#ifdef __GNUG__
-#pragma implementation "liner.cpp"
-#endif
-
-// For compilers that support precompilation, includes "wx/wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include <math.h>
-
-#include <stdlib.h>
-
-#include "wx/canvas/liner.h"
-
-wxLine::wxLine( double x1, double y1, double x2, double y2 )
-{
- m_AA = 0.0;
- m_BB = 0.0;
- m_CC = 0.0;
-
- m_a=wxPoint2DDouble(x1,y1);
- m_b=wxPoint2DDouble(x2,y2);
- if (m_a==m_b)
- assert(0);
-
- m_valid_parameters = FALSE;
-}
-
-wxLine::~wxLine()
-{
-}
-
-wxLine::wxLine(const wxPoint2DDouble& a,const wxPoint2DDouble& b)
-{
- if (a==b)
- assert(0);
-
- m_a=a;
- m_b=b;
- m_valid_parameters = FALSE;
-}
-
-
-
-// ActionOnTable1
-// This function decide which action must be taken, after PointInLine
-// has given the results of two points in relation to a wxLine. See table 1 in the report
-//
-// input Result_beginPoint:
-// Result_endPoint :
-// The results can be R_R_LEFT_SIDE, R_R_RIGHT_SIDE, R_R_ON_AREA, R_R_IN_AREA
-//
-// return -1: Illegal combination
-// 0: No action, no crosspoints
-// 1: Investigate results points in relation to the other wxLine
-// 2: endPoint is a crosspoint, no further investigation
-// 3: beginPoint is a crosspoint, no further investigation
-// 4: beginPoint and endPoint are crosspoints, no further investigation
-// 5: beginPoint is a crosspoint, need further investigation
-// 6: endPoint is a crosspoint, need further investigation
-int wxLine::ActionOnTable1(R_PointStatus Result_beginPoint, R_PointStatus Result_endPoint)
-{
- // beginPoint and endPoint are crosspoints
- if (
- (Result_beginPoint == R_IN_AREA)
- &&
- (Result_endPoint == R_IN_AREA)
- )
- return 4;
- // there are no crosspoints, no action
- if (
- (
- (Result_beginPoint == R_LEFT_SIDE)
- &&
- (Result_endPoint == R_LEFT_SIDE)
- )
- ||
- (
- (Result_beginPoint == R_RIGHT_SIDE)
- &&
- (Result_endPoint == R_RIGHT_SIDE)
- )
- )
- return 0;
- // maybe there is a crosspoint, further investigation needed
- if (
- (
- (Result_beginPoint == R_LEFT_SIDE)
- &&
- (
- (Result_endPoint == R_RIGHT_SIDE)
- ||
- (Result_endPoint == R_ON_AREA)
- )
- )
- ||
- (
- (Result_beginPoint == R_RIGHT_SIDE)
- &&
- (
- (Result_endPoint == R_LEFT_SIDE)
- ||
- (Result_endPoint == R_ON_AREA)
- )
- )
- ||
- (
- (Result_beginPoint == R_ON_AREA)
- &&
- (
- (Result_endPoint == R_LEFT_SIDE)
- ||
- (Result_endPoint == R_RIGHT_SIDE)
- ||
- (Result_endPoint == R_ON_AREA)
- )
- )
- )
- return 1;
- //there is a crosspoint
- if (
- (
- (Result_beginPoint == R_LEFT_SIDE)
- ||
- (Result_beginPoint == R_RIGHT_SIDE)
- )
- &&
- (Result_endPoint == R_IN_AREA)
- )
- return 2;
- // there is a crosspoint
- if (
- (Result_beginPoint == R_IN_AREA)
- &&
- (
- (Result_endPoint == R_LEFT_SIDE)
- ||
- (Result_endPoint == R_RIGHT_SIDE)
- )
- )
- return 3;
- // beginPoint is a crosspoint, further investigation needed
- if (
- (Result_beginPoint == R_IN_AREA)
- &&
- (Result_endPoint == R_ON_AREA)
- )
- return 5;
- // endPoint is a crosspoint, further investigation needed
- if (
- (Result_beginPoint == R_ON_AREA)
- &&
- (Result_endPoint == R_IN_AREA)
- )
- return 6;
- // All other combinations are illegal
- return -1;
-}
-
-
-// ActionOnTable2
-// This function decide which action must be taken, after PointInLine
-// has given the results of two points in relation to a wxLine. It can only give a
-// correct decision if first the relation of the points from the wxLine
-// are investigated in relation to the wxLine wich can be constucted from the points.
-//
-// input Result_beginPoint:
-// Result_endPoint :
-// The results can be R_LEFT_SIDE, R_RIGHT_SIDE, R_ON_AREA, R_IN_AREA
-//
-// return -1: Illegal combination
-// 0: No action, no crosspoints
-// 1: Calculate crosspoint
-// 2: endPoint is a crosspoint
-// 3: beginPoint is a crosspoint
-// 4: beginPoint and endPoint are crosspoints
-int wxLine::ActionOnTable2(R_PointStatus Result_beginPoint, R_PointStatus Result_endPoint)
-{
- // beginPoint and eindpoint are crosspoints
- if (
- (Result_beginPoint == R_IN_AREA)
- &&
- (Result_endPoint == R_IN_AREA)
- )
- return 4;
- // there are no crosspoints
- if (
- (
- (Result_beginPoint == R_LEFT_SIDE)
- &&
- (
- (Result_endPoint == R_LEFT_SIDE)
- ||
- (Result_endPoint == R_ON_AREA)
- )
- )
- ||
- (
- (Result_beginPoint == R_RIGHT_SIDE)
- &&
- (
- (Result_endPoint == R_RIGHT_SIDE)
- ||
- (Result_endPoint == R_ON_AREA)
- )
- )
- ||
- (
- (Result_beginPoint == R_ON_AREA)
- &&
- (
- (Result_endPoint == R_LEFT_SIDE)
- ||
- (Result_endPoint == R_RIGHT_SIDE)
- ||
- (Result_endPoint == R_ON_AREA)
- )
- )
- )
- return 0;
- // there is a real intersection, which must be calculated
- if (
- (
- (Result_beginPoint == R_LEFT_SIDE)
- &&
- (Result_endPoint == R_RIGHT_SIDE)
- )
- ||
- (
- (Result_beginPoint == R_RIGHT_SIDE)
- &&
- (Result_endPoint == R_LEFT_SIDE)
- )
- )
- return 1;
- // endPoint is a crosspoint
- if (
- (
- (Result_beginPoint == R_LEFT_SIDE)
- ||
- (Result_beginPoint == R_RIGHT_SIDE)
- ||
- (Result_beginPoint == R_ON_AREA)
- )
- &&
- (Result_endPoint == R_IN_AREA)
- )
- return 2;
- // beginPoint is a crosspoint
- if (
- (Result_beginPoint == R_IN_AREA)
- &&
- (
- (Result_endPoint == R_LEFT_SIDE)
- ||
- (Result_endPoint == R_RIGHT_SIDE)
- ||
- (Result_endPoint == R_ON_AREA)
- )
- )
- return 3;
- // All other combinations are illegal
- return -1;
-}
-
-// Calculate the Y when the X is given
-double wxLine::Calculate_Y(double X)
-{
- CalculateLineParameters();
- if (m_AA != 0)
- return -(m_AA * X + m_CC) / m_BB;
- else
- // horizontal wxLine
- return m_a.m_y;
-}
-
-void wxLine::Virtual_Point(wxPoint2DDouble& a_point,double distance) const
-{
- assert(m_valid_parameters);
-
- //calculate the distance using the slope of the wxLine
- //and rotate 90 degrees
-
- a_point.m_y=a_point.m_y + (distance * -m_BB);
- a_point.m_x=a_point.m_x - (distance * m_AA );
-}
-
-
-
-//
-// Calculate the lineparameters for the wxLine if nessecary
-//
-void wxLine::CalculateLineParameters()
-{
- // if not valid_parameters calculate the parameters
- if (!m_valid_parameters)
- {
- double length;
-
- // bp AND ep may not be the same
- if (m_a == m_b)
- assert (0);
-
- m_AA = (m_b.m_y - m_a.m_y); // A = (Y2-Y1)
- m_BB = (m_a.m_x - m_b.m_x); // B = (X1-X2)
-
- // the parameters A end B can now be normalized
- length = sqrt(m_AA*m_AA + m_BB*m_BB);
-
- assert(length !=0);
-
- m_AA = (m_AA / length);
- m_BB = (m_BB / length);
-
- m_CC = -((m_AA * m_a.m_x) + (m_a.m_y * m_BB));
-
- m_valid_parameters = TRUE;
- }
-}
-
-
-// Checks if a wxLine intersect with another wxLine
-// inout wxLine : another wxLine
-// Marge: optional, standard on MARGE (declared in MISC.CPP)
-//
-// return true : wxLines are crossing
-// false: wxLines are not crossing
-//
-bool wxLine::CheckIntersect (wxLine& lijn, double Marge)
-{
- double distance=0;
-
- // bp AND ep may not be the same
- if (m_a == m_b)
- assert (0);
-
- int Take_Action1, Take_Action2;
- bool Total_Result=FALSE;
- R_PointStatus Result_beginPoint,Result_endPoint;
-
- Result_beginPoint = PointInLine(lijn.m_a,distance,Marge);
- Result_endPoint = PointInLine(lijn.m_b,distance,Marge);
- Take_Action1 = ActionOnTable1(Result_beginPoint,Result_endPoint);
- switch (Take_Action1)
- {
- case 0: Total_Result = FALSE ; break;
- case 1: {
- Result_beginPoint = lijn.PointInLine(m_a,distance,Marge);
- Result_endPoint = lijn.PointInLine(m_b,distance,Marge);
- Take_Action2 = ActionOnTable2(Result_beginPoint,Result_endPoint);
- switch (Take_Action2)
- {
- case 0: Total_Result = FALSE; break;
- case 1: case 2: case 3: case 4: Total_Result = TRUE; break;
- }
- }; break; // This break belongs to the switch(Take_Action1)
- case 2: case 3: case 4: case 5: case 6: Total_Result = TRUE; break;
- }
- return Total_Result; //This is the final decision
-}
-
-
-//
-// Get the beginPoint from the wxLine
-// usage: Point aPoint = a_line.GetBeginPoint()
-//
-wxPoint2DDouble wxLine::GetBeginPoint()
-{
- return m_a;
-}
-
-
-//
-// Get the endPoint from the wxLine
-// usage: Point aPoint = a_line.GetEndPoint()
-//
-wxPoint2DDouble wxLine::GetEndPoint()
-{
- return m_b;
-}
-
-// Intersects two wxLines
-// input wxLine : another wxLine
-// Marge: optional, standard on MARGE
-//
-// return 0: If there are no crossings
-// 1: If there is one crossing
-// 2: If there are two crossings
-int wxLine::Intersect(wxLine& lijn, wxPoint2DDouble& c1 ,wxPoint2DDouble& c2 , double Marge)
-{
- double distance=0;
-
- // bp AND ep may not be the same
- if (m_a == m_b)
- assert (0);
-
- R_PointStatus Result_beginPoint,Result_endPoint;
- int Take_Action1, Take_Action2, Number_of_Crossings = 0;
-
- Result_beginPoint = PointInLine(lijn.m_a,distance,Marge);
- Result_endPoint = PointInLine(lijn.m_b,distance,Marge);
-
- Take_Action1 = ActionOnTable1(Result_beginPoint,Result_endPoint);
-// 0: No action, no crosspoints
-// 1: Investigate results points in relation to the other wxLine
-// 2: endPoint is a crosspoint, no further investigation
-// 3: beginPoint is a crosspoint, no further investigation
-// 4: beginPoint and endPoint are crosspoints, no further investigation
-// 5: beginPoint is a crosspoint, need further investigation
-// 6: endPoint is a crosspoint, need further investigation
-
- // The first switch will insert a crosspoint immediatly
- switch (Take_Action1)
- {
- case 2: case 6: c1=lijn.m_b;
- Number_of_Crossings = 1;
- break;
- case 3: case 5: c1=lijn.m_a;
- Number_of_Crossings = 1;
- break;
- case 4: c1=lijn.m_a;
- c2=lijn.m_b;
- Number_of_Crossings = 2;
- break;
- default:
- break;
- }
-
- // This switch wil investigate the points of this wxLine in relation to lijn
- // 1: Investigate results points in relation to the other wxLine
- // 5: beginPoint is a crosspoint, need further investigation
- // 6: endPoint is a crosspoint, need further investigation
- switch (Take_Action1)
- {
- case 1: case 5: case 6:
- {
- Result_beginPoint = lijn.PointInLine(m_a,distance,Marge);
- Result_endPoint = lijn.PointInLine(m_b,distance,Marge);
- Take_Action2 = ActionOnTable2(Result_beginPoint,Result_endPoint);
- // return -1: Illegal combination
- // 0: No action, no crosspoints
- // 1: Calculate crosspoint
- // 2: endPoint is a crosspoint
- // 3: beginPoint is a crosspoint
- // 4: beginPoint and endPoint are crosspoints
- switch (Take_Action2)
- {
- // for the cases see the returnvalue of ActionTable2
- case 1: { // begin of scope to calculate the intersection
- double X, Y, Denominator;
- CalculateLineParameters();
- Denominator = (m_AA * lijn.m_BB) - (lijn.m_AA * m_BB);
- // Denominator may not be 0
- assert(Denominator != 0.0);
- // Calculate intersection of both linesegments
- X = ((m_BB * lijn.m_CC) - (lijn.m_BB * m_CC)) / Denominator;
- Y = ((lijn.m_AA * m_CC) - (m_AA * lijn.m_CC)) / Denominator;
-
- c1.m_x=X;
- c1.m_y=Y;
- }
- Number_of_Crossings++;
- break;
- case 2: c2=m_a;
- Number_of_Crossings++;
- break;
- case 3: c2=m_b;
- Number_of_Crossings++;
- break;
- case 4: c1=m_a;
- c2=m_b;
- Number_of_Crossings = 2;
- break;
- }
- };
- break;
- default:
- break;
- }
- return Number_of_Crossings; //This is de final number of crossings
-}
-
-//
-// test if a point lies in the linesegment. If the point isn't on the wxLine
-// the function returns a value that indicates on which side of the
-// wxLine the point is (in linedirection from first point to second point
-//
-// returns R_LEFT_SIDE, when point lies on the left side of the wxLine
-// R_RIGHT_SIDE, when point lies on the right side of the wxLine
-// R_ON_AREA, when point lies on the infinite wxLine within a range
-// R_IN_AREA, when point lies in the area of the linesegment
-// the returnvalues are declared in (wxLine.H)
-R_PointStatus wxLine::PointInLine(const wxPoint2DDouble& a_Point, double& Distance,double Marge)
-{
- Distance=0;
-
- // Point may not be the same
- assert(m_a != m_b);
-
- int Result_ofm_BBox=FALSE;
- R_PointStatus Result_of_Online;
-
- //quick test if point is begin or endpoint
- if (a_Point == m_a || a_Point == m_b)
- return R_IN_AREA;
-
- // Checking if point is in bounding-box with marge
- double xmin=wxMin(m_a.m_x,m_b.m_x);
- double xmax=wxMax(m_a.m_x,m_b.m_x);
- double ymin=wxMin(m_a.m_y,m_b.m_y);
- double ymax=wxMax(m_a.m_y,m_b.m_y);
-
- if ( a_Point.m_x >= (xmin - Marge) && a_Point.m_x <= (xmax + Marge) &&
- a_Point.m_y >= (ymin - Marge) && a_Point.m_y <= (ymax + Marge) )
- Result_ofm_BBox=TRUE;
-
- // Checking if point is on the infinite wxLine
- Result_of_Online = PointOnLine(a_Point, Distance, Marge);
-
- // point in boundingbox of the wxLine and is on the wxLine then the point is R_IN_AREA
- if ((Result_ofm_BBox) && (Result_of_Online == R_ON_AREA))
- return R_IN_AREA;
- else
- return Result_of_Online;
-}
-
-
-//
-// test if a point lies on the wxLine. If the point isn't on the wxLine
-// the function returns a value that indicates on which side of the
-// wxLine the point is (in linedirection from first point to second point
-//
-// returns R_LEFT_SIDE, when point lies on the left side of the wxLine
-// R_ON_AREA, when point lies on the infinite wxLine within a range
-// R_RIGHT_SIDE, when point lies on the right side of the wxLine
-// R_LEFT_SIDE , R_RIGHT_SIDE , R_ON_AREA
-R_PointStatus wxLine::PointOnLine(const wxPoint2DDouble& a_Point, double& Distance, double Marge)
-{
- Distance=0;
- // Point may not be queal
- assert(m_a!=m_b);
-
- //quick test if point is begin or endpoint
- if (a_Point == m_a || a_Point == m_b)
- return R_ON_AREA;
-
- CalculateLineParameters();
- // calculate the distance of a_Point in relation to the wxLine
- Distance = (m_AA * a_Point.m_x)+(m_BB * a_Point.m_y) + m_CC;
-
- if (Distance < -Marge)
- return R_LEFT_SIDE;
- else
- {
- if (Distance > Marge)
- return R_RIGHT_SIDE;
- else
- return R_ON_AREA;
- }
-}
-
-// makes a wxLine same as these
-// usage : wxLine1 = wxLine2;
-wxLine& wxLine::operator=(const wxLine& a_line)
-{
- m_AA = a_line.m_AA;
- m_BB = a_line.m_BB;
- m_CC = a_line.m_CC;
-
- m_a= a_line.m_a;
- m_b= a_line.m_b;
- m_valid_parameters = a_line.m_valid_parameters;
- return *this;
-}
-
-void wxLine::OffsetContour(const wxLine& nextline,double factor,wxPoint2DDouble& offsetpoint) const
-{
- wxPoint2DDouble offs_begin(m_a);
- wxPoint2DDouble offs_end(m_b);
-
- wxPoint2DDouble offs_bgn_next(nextline.m_a);
- wxPoint2DDouble offs_end_next(nextline.m_b);
- // make a wxPoint2DDouble from this point
-
- Virtual_Point(offs_begin,factor);
- Virtual_Point(offs_end,factor);
- wxLine offs_currentline(offs_begin,offs_end);
-
- nextline.Virtual_Point(offs_bgn_next,factor);
- nextline.Virtual_Point(offs_end_next,factor);
- wxLine offs_nextline(offs_bgn_next, offs_end_next);
-
- offs_nextline.CalculateLineParameters();
- offs_currentline.CalculateLineParameters();
- offs_currentline.Intersect(offs_nextline,offsetpoint);
-}
-
-// Return the position of the second wxLine compared to this wxLine
-// Result = IS_ON | IS_LEFT | IS_RIGHT
-// Here Left and Right is defined as being left or right from
-// the this wxLine towards the center (common) node
-// direction of vetors taken as begin to endpoint with end of this at
-// begin of wxLine two
-OUTPRODUCT wxLine::OutProduct(const wxLine& two,double accur)
-{
- R_PointStatus uitp;
- double distance;
- if (two.m_a==two.m_b)
- assert(0);
- if (m_a==m_b)
- assert(0);
-
- uitp=PointOnLine(two.m_b, distance, accur);
-
-
- /*double uitp= (_x - first._x) * (third._y - _y) -
- (_y - first._y) * (third._x - _x);
- if (uitp>0) return IS_LEFT;
- if (uitp<0) return IS_RIGHT;
- return IS_ON;*/
-
- //depending on direction of this link (going to or coming from centre)
- if (uitp==R_LEFT_SIDE)
- return R_IS_LEFT;
- if (uitp==R_RIGHT_SIDE)
- return R_IS_RIGHT;
- return R_IS_ON;
-}
-
-// Intersects two lines if a crossing return TRUE
-// else FALSE
-bool wxLine::Intersect(wxLine& lijn,wxPoint2DDouble& crossing)
-{
- // lijn must exist
- assert(m_valid_parameters);
- assert(lijn.m_valid_parameters);
-
- double X, Y, Denominator;
- Denominator = (m_AA * lijn.m_BB) - (lijn.m_AA * m_BB);
- // Denominator may not be 0
- if (Denominator == 0.0)
- return FALSE;
- // Calculate intersection of both linesegments
- X = ((m_BB * lijn.m_CC) - (lijn.m_BB * m_CC)) / Denominator;
- Y = ((lijn.m_AA * m_CC) - (m_AA * lijn.m_CC)) / Denominator;
-
- crossing.m_x=X;
- crossing.m_y=Y;
- return TRUE;
-}
-
+++ /dev/null
-#
-# File: makefile.b32
-# Author: Julian Smart
-# Created: 1999
-# Updated:
-# Copyright:
-#
-# Makefile : Builds Canvas library for 32-bit BC++
-
-WXDIR = $(WXWIN)
-
-LIBTARGET=$(WXDIR)\lib\canvas.lib
-
-OBJECTS = bbox.obj canvas.obj liner.obj polygon.obj
-
-!include $(WXDIR)\src\makelib.b32
-
+++ /dev/null
-#
-# File: makefile.g95
-# Author: Julian Smart
-# Created: 1999
-# Updated:
-# Copyright: (c) Julian Smart, 1999
-#
-# Makefile for wxWindows Plot library Cygwin/Mingw32).
-
-WXDIR = ../../..
-
-LIBTARGET=$(WXDIR)/lib/libcanvas.a
-OBJECTS = bbox.o canvas.o liner.o polygon.o
-
-include $(WXDIR)/src/makelib.g95
-
+++ /dev/null
-
-# File: makefile.vc
-# Author: Julian Smart
-# Created: 2001
-# Updated:
-# Copyright: (c) 2001, Julian Smart
-#
-# "%W% %G%"
-#
-# Makefile : Builds Plot class library (MS VC++).
-# Use FINAL=1 argument to nmake to build final version with no debugging
-# info
-
-
-# Set WXDIR for your system
-WXDIR = $(WXWIN)
-GIZMOSDIR = $(WXDIR)\contrib\src\canvas
-GIZMOSINC = $(WXDIR)\contrib\include\wx\canvas
-THISDIR = $(WXDIR)\contrib\src\canvas
-DOCDIR=$(WXDIR)\contrib\docs
-LOCALDOCDIR=$(WXDIR)\contrib\docs\latex\canvas
-
-!include $(WXDIR)\src\makevc.env
-
-OBJECTS = $(D)\bbox.obj $(D)\canvas.obj $(D)\liner.obj $(D)\polygon.obj
-
-LIBTARGET=$(WXDIR)\lib\canvas$(LIBEXT).lib
-
-all: $(D) $(LIBTARGET)
-
-$(D) :
- mkdir $(D)
-
-wx:
- cd $(WXDIR)\src\msw
- nmake -f makefile.vc FINAL=$(FINAL)
- cd $(THISDIR)
-
-wxclean:
- cd $(WXDIR)\src\msw
- nmake -f makefile.vc clean
- cd $(THISDIR)
-
-$(LIBTARGET): $(OBJECTS)
- -erase $(LIBTARGET)
- $(implib) @<<
--out:$(LIBTARGET)
--machine:$(CPU)
-$(OBJECTS)
-<<
-
-$(D)\bbox.obj: bbox.$(SRCSUFF)
- cl @<<
-$(CPPFLAGS) /c /Fo$@ /Tp $(*B).$(SRCSUFF)
-<<
-
-$(D)\canvas.obj: canvas.$(SRCSUFF)
- cl @<<
-$(CPPFLAGS) /c /Fo$@ /Tp $(*B).$(SRCSUFF)
-<<
-
-$(D)\liner.obj: liner.$(SRCSUFF)
- cl @<<
-$(CPPFLAGS) /c /Fo$@ /Tp $(*B).$(SRCSUFF)
-<<
-
-$(D)\polygon.obj: polygon.$(SRCSUFF)
- cl @<<
-$(CPPFLAGS) /c /Fo$@ /Tp $(*B).$(SRCSUFF)
-<<
-
-clean:
- -erase $(D)\*.obj
- -erase *.sbr
- -erase *.exe
- -erase *.res
- -erase *.map
- -erase *.pdb
- -erase $(LIBTARGET)
-
-DOCSOURCES=$(LOCALDOCDIR)\canvas.tex \
- $(LOCALDOCDIR)\bugs.tex $(LOCALDOCDIR)\changes.tex\
- $(LOCALDOCDIR)\classes.tex $(LOCALDOCDIR)\intro.tex\
- $(LOCALDOCDIR)\topics.tex $(LOCALDOCDIR)\sample.tex
-
-html: $(DOCDIR)\html\canvas\canvas.htm
-htmlhelp: $(DOCDIR)\htmlhelp\canvas.chm
-htb: $(DOCDIR)\htb\canvas.htb
-hlp: $(DOCDIR)\winhelp\canvas.hlp
-pdfrtf: $(DOCDIR)\pdf\canvas.rtf
-ps: $(DOCDIR)\ps\canvas.ps
-
-touchmanual:
- touch $(LOCALDOCDIR)\canvas.tex
-
-
-$(DOCDIR)\winhelp\canvas.hlp: $(LOCALDOCDIR)\canvas.rtf $(LOCALDOCDIR)\canvas.hpj
- cd $(LOCALDOCDIR)
- -erase canvas.ph
- hc canvas
- move canvas.hlp $(DOCDIR)\winhelp\canvas.hlp
- move canvas.cnt $(DOCDIR)\winhelp\canvas.cnt
- cd $(THISDIR)
-
-$(LOCALDOCDIR)\canvas.rtf: $(DOCSOURCES)
- cd $(LOCALDOCDIR)
- -start $(WAITFLAG) tex2rtf $(LOCALDOCDIR)\canvas.tex $(LOCALDOCDIR)\canvas.rtf -twice -winhelp
- cd $(THISDIR)
-
-$(DOCDIR)\pdf\canvas.rtf: $(DOCSOURCES)
- cd $(LOCALDOCDIR)
- -copy *.bmp $(DOCDIR)\pdf
- -start $(WAITFLAG) tex2rtf $(LOCALDOCDIR)\canvas.tex $(DOCDIR)\pdf\canvas.rtf -twice -rtf
- cd $(THISDIR)
-
-$(DOCDIR)\html\canvas\canvas.htm: $(DOCSOURCES)
- cd $(LOCALDOCDIR)
- -mkdir $(DOCDIR)\html\canvas
- copy *.gif $(DOCDIR)\html\canvas
- -start $(WAITFLAG) tex2rtf $(LOCALDOCDIR)\canvas.tex $(DOCDIR)\html\canvas\canvas.htm -twice -html
- -erase $(DOCDIR)\html\canvas\*.con
- -erase *.con
- -erase $(DOCDIR)\html\canvas\*.ref
- cd $(THISDIR)
-
-$(DOCDIR)\htmlhelp\canvas.chm: $(DOCDIR)\html\canvas\canvas.htm $(DOCDIR)\html\canvas\canvas.hhp
- cd $(DOCDIR)\html\canvas
- -hhc canvas.hhp
- move canvas.chm $(DOCDIR)\htmlhelp\canvas.chm
- cd $(THISDIR)
-
-# An htb file is a zip file containing the .htm, .gif, .hhp, .hhc and .hhk
-# files, renamed to htb.
-# This can then be used with e.g. helpview.
-# Optionally, a cached version of the .hhp file can be generated with hhp2cached.
-$(DOCDIR)\htb\canvas.htb: $(DOCDIR)\html\canvas\canvas.htm
- cd $(DOCDIR)\html\canvas
- -erase canvas.zip canvas.htb
- zip canvas.zip *.htm *.gif *.hhp *.hhc *.hhk
- -mkdir $(DOCDIR)\htb
- move canvas.zip $(DOCDIR)\htb\canvas.htb
- cd $(THISDIR)
-
-$(LOCALDOCDIR)\canvas.dvi: $(DOCSOURCES)
- cd $(LOCALDOCDIR)
- -latex canvas
- -latex canvas
- -makeindx canvas
- -bibtex canvas
- -latex canvas
- -latex canvas
- cd $(THISDIR)
-
-$(WXDIR)\docs\ps\canvas.ps: $(LOCALDOCDIR)\canvas.dvi
- cd $(LOCALDOCDIR)
- -dvips32 -o canvas.ps canvas
- move canvas.ps $(WXDIR)\docs\ps\canvas.ps
- cd $(THISDIR)
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: polygon.cpp
-// Author: Klaas Holwerda
-// Created: XX/XX/XX
-// Copyright: 2000 (c) Klaas Holwerda
-// Licence: wxWindows Licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifdef __GNUG__
- #pragma implementation "polygon.cpp"
-#endif
-
-// For compilers that support precompilation, includes "wx/wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/canvas/polygon.h"
-#include "wx/canvas/liner.h"
-
-void ConvertSplinedPolygon(wxList* list, double Aber);
-void ConvertSplinedPolyline(wxList* list,double Aber);
-void ConvertSplinedPolygon(int& n, wxPoint2DDouble* points[], double Aber);
-static void GetLRO(const wxPoint2DDouble& P, const wxPoint2DDouble& p1, const wxPoint2DDouble& p2, int &LRO1, int &LRO2,const double marge);
-
-//----------------------------------------------------------------------------
-// wxCanvasPolyline
-//----------------------------------------------------------------------------
-
-wxCanvasPolyline::wxCanvasPolyline( int n, wxPoint2DDouble points[])
- : wxCanvasObject()
-{
- m_n = n;
- m_points = points;
- m_pen = *wxBLACK_PEN;
-
- CalcBoundingBox();
-}
-
-wxCanvasPolyline::~wxCanvasPolyline()
-{
- delete m_points;
-}
-
-void wxCanvasPolyline::SetPosXY( double x, double y)
-{
- double xo=m_points[0].m_x;
- double yo=m_points[0].m_y;
- int i;
- for (i=0; i < m_n;i++)
- {
- m_points[i].m_x += (x-xo);
- m_points[i].m_y += (y-yo);
- }
- CalcBoundingBox();
-}
-
-void wxCanvasPolyline::TransLate( double x, double y )
-{
- int i;
- for (i=0; i < m_n;i++)
- {
- m_points[i].m_x += x;
- m_points[i].m_y += y;
- }
- CalcBoundingBox();
-}
-
-void wxCanvasPolyline::CalcBoundingBox()
-{
- m_bbox.SetValid(FALSE);
-
- int i;
- for (i=0; i < m_n;i++)
- {
- m_bbox.Expand( m_points[i].m_x,m_points[i].m_y);
- }
-
- //include the pen width also
- m_bbox.EnLarge(m_pen.GetWidth());
-}
-
-void wxCanvasPolyline::Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height )
-{
- if (!m_visible) return;
-
- int start_y = clip_y;
- int end_y = clip_y+clip_height;
-
- int start_x = clip_x;
- int end_x = clip_x+clip_width;
-
-#if IMAGE_CANVAS
-#else
- wxPoint *cpoints = new wxPoint[m_n];
- int i;
- for (i = 0; i < m_n; i++)
- {
- double x1;
- double y1;
- //transform to absolute
- cworld->TransformPoint( m_points[i].m_x, m_points[i].m_y, x1, y1 );
- //transform to device
- cpoints[i].x = m_admin->LogicalToDeviceX(x1);
- cpoints[i].y = m_admin->LogicalToDeviceY(y1);
- }
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetClippingRegion(start_x,start_y,end_x-start_x,end_y-start_y);
- int pw=m_pen.GetWidth();
- m_pen.SetWidth(m_admin->LogicalToDeviceXRel(pw));
- dc->SetPen(m_pen);
- dc->DrawLines(m_n, cpoints, 0,0);
- delete [] cpoints;
- dc->SetPen(wxNullPen);
- dc->DestroyClippingRegion();
- m_pen.SetWidth(pw);
-#endif
-}
-
-void wxCanvasPolyline::WriteSVG( wxTextOutputStream &stream )
-{
-}
-
-wxCanvasObject* wxCanvasPolyline::IsHitWorld( double x, double y, double margin )
-{
- if ((x >= m_bbox.GetMinX()-margin) &&
- (x <= m_bbox.GetMaxX()+margin) &&
- (y >= m_bbox.GetMinY()-margin) &&
- (y <= m_bbox.GetMaxY()+margin)
- )
- {
- wxPoint2DDouble P=wxPoint2DDouble(x,y);
- if (PointOnPolyline(P,m_pen.GetWidth()/2+margin))
- return this;
- else
- return (wxCanvasObject*) NULL;
- }
- return (wxCanvasObject*) NULL;
-}
-
-bool wxCanvasPolyline::PointOnPolyline(const wxPoint2DDouble& P, double margin)
-{
- bool result = FALSE;
- double distance;
- wxPoint2DDouble p1,p2;
-
- p2=m_points[0];
- int i;
- for (i = 0; i < m_n-1; i++)
- {
- p1=p2;
- p2=m_points[i+1];
- if (margin > sqrt(pow(p1.m_x-P.m_x,2)+pow(p1.m_y-P.m_y,2)))
- {
- result=TRUE;
- break;
- }
- else if (!((p1.m_x == p2.m_x) && (p1.m_y == p2.m_y)))
- {
- wxLine line1(p1,p2);
- if (line1.PointInLine(P,distance,margin) == R_IN_AREA)
- {
- result=TRUE;
- break;
- }
- }
- }
-
- return result;
-}
-
-//----------------------------------------------------------------------------
-// wxCanvasPolygon
-//----------------------------------------------------------------------------
-
-wxCanvasPolygon::wxCanvasPolygon( int n, wxPoint2DDouble points[],bool splined)
- : wxCanvasObject()
-{
- m_n = n;
- m_points = points;
- m_brush = *wxBLACK_BRUSH;
- m_pen = *wxTRANSPARENT_PEN;
- m_textfg=*wxBLACK;
- m_textbg=*wxWHITE;
- m_transp=FALSE;
- m_gpen=*wxBLACK_PEN;
- m_gdistance=0;
- m_gradient=FALSE;
- m_spline = splined;
-
- if (m_spline)
- {
- ConvertSplinedPolygon(m_n, &m_points, 10 );
- }
-
- CalcBoundingBox();
-}
-
-wxCanvasPolygon::~wxCanvasPolygon()
-{
- delete m_points;
-}
-
-void wxCanvasPolygon::SetPosXY( double x, double y)
-{
- double xo=m_points[0].m_x;
- double yo=m_points[0].m_y;
- int i;
- for (i=0; i < m_n;i++)
- {
- m_points[i].m_x += (x-xo);
- m_points[i].m_y += (y-yo);
- }
- CalcBoundingBox();
-}
-
-void wxCanvasPolygon::TransLate( double x, double y )
-{
- int i;
- for (i=0; i < m_n;i++)
- {
- m_points[i].m_x += x;
- m_points[i].m_y += y;
- }
- CalcBoundingBox();
-}
-
-void wxCanvasPolygon::CalcBoundingBox()
-{
-
- m_bbox.SetValid(FALSE);
-
- int i;
- for (i=0; i < m_n;i++)
- {
- m_bbox.Expand( m_points[i].m_x,m_points[i].m_y);
- }
-
- //include the pen width also
- m_bbox.EnLarge(m_pen.GetWidth());
-}
-
-void wxCanvasPolygon::Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height )
-{
- if (!m_visible) return;
-
- int start_y = clip_y;
- int end_y = clip_y+clip_height;
-
- int start_x = clip_x;
- int end_x = clip_x+clip_width;
-
-#if IMAGE_CANVAS
-#else
- //one extra for drawlines in some cases
- wxPoint *cpoints = new wxPoint[m_n+1];
- int i;
- for (i = 0; i < m_n; i++)
- {
- double x1;
- double y1;
- cworld->TransformPoint( m_points[i].m_x, m_points[i].m_y, x1, y1 );
- cpoints[i].x = m_admin->LogicalToDeviceX(x1);
- cpoints[i].y = m_admin->LogicalToDeviceY(y1);
- }
- double x1;
- double y1;
- cworld->TransformPoint( m_points[0].m_x, m_points[0].m_y, x1, y1 );
- cpoints[m_n].x = m_admin->LogicalToDeviceX(x1);
- cpoints[m_n].y = m_admin->LogicalToDeviceY(y1);
-
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetClippingRegion(start_x,start_y,end_x-start_x,end_y-start_y);
- dc->SetBrush(m_brush);
- int pw=m_pen.GetWidth();
- m_pen.SetWidth(m_admin->LogicalToDeviceXRel(pw));
- if ( m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE && m_transp)
- {
- //draw a transparent polygon
- //leaf the pen not transparent, which i prefer
- dc->SetPen( wxPen( *wxWHITE,m_admin->LogicalToDeviceXRel(pw), wxSOLID) );
- dc->SetTextForeground(*wxBLACK);
- dc->SetTextBackground(*wxWHITE);
- dc->SetLogicalFunction(wxAND_INVERT);
- // BLACK OUT the opaque pixels and leave the rest as is
- dc->DrawPolygon(m_n, cpoints, 0,0,wxWINDING_RULE);
- // Set background and foreground colors for fill pattern
- //the previous blacked out pixels are now merged with the layer color
- //while the non blacked out pixels stay as they are.
- dc->SetTextForeground(*wxBLACK);
- //now define what will be the color of the fillpattern parts that are not transparent
- dc->SetTextBackground(m_textfg);
- dc->SetLogicalFunction(wxOR);
- //don't understand how but the outline is also depending on logicalfunction
- dc->SetPen(m_pen);
- dc->DrawPolygon(m_n, cpoints, 0,0,wxWINDING_RULE);
- }
- else if (m_gradient)
- {
- int pw2=m_gpen.GetWidth();
- m_gpen.SetWidth(m_admin->LogicalToDeviceYRel(pw2));
- FillPolygon(cworld,clip_x,clip_y,clip_width,clip_height );
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- dc->SetPen(m_pen);
- dc->DrawLines(m_n+1, cpoints, 0,0);
- }
- m_gpen.SetWidth(pw2);
- }
- else
- {
- dc->SetPen(m_pen);
- dc->DrawPolygon(m_n, cpoints, 0,0,wxWINDING_RULE);
- }
- delete [] cpoints;
- dc->SetBrush(wxNullBrush);
- dc->SetPen(wxNullPen);
- dc->DestroyClippingRegion();
- m_pen.SetWidth(pw);
-#endif
-}
-
-void wxCanvasPolygon::WriteSVG( wxTextOutputStream &stream )
-{
-}
-
-wxCanvasObject* wxCanvasPolygon::IsHitWorld( double x, double y, double margin )
-{
- if ((x >= m_bbox.GetMinX()-margin) &&
- (x <= m_bbox.GetMaxX()+margin) &&
- (y >= m_bbox.GetMinY()-margin) &&
- (y <= m_bbox.GetMaxY()+margin)
- )
- {
- wxPoint2DDouble P=wxPoint2DDouble(x,y);
- INOUTPOLY io=PointInPolygon(P, m_pen.GetWidth()/2+margin);
- if (io == OUTSIDE_POLY)
- return (wxCanvasObject*) NULL;
- else
- return this;
- }
- return (wxCanvasObject*) NULL;
-}
-
-INOUTPOLY wxCanvasPolygon::PointInPolygon(const wxPoint2DDouble& P, double marge)
-{
- int R_tot = 0, L_tot = 0;
- int p1_LRO, p2_LRO;
- double px = P.m_x, py = P.m_y;
- double Y_intersect;
- wxPoint2DDouble p1,p2;
-
- //iterate across points until we are sure that the given point is in or out
- int i;
- for (i = 0; i < m_n; i++)
- {
- p1 = m_points[i];
- if (i == m_n-1)
- p2 = m_points[0];
- else
- p2 = m_points[i+1];
-
- //more accurate
- GetLRO(P,p1,p2,p1_LRO,p2_LRO,marge/10);
- if (p1_LRO != p2_LRO)
- {
- int L = 0, R = 0;
- if (p2_LRO == -1) { R = -p1_LRO; L = 1; }
- if (p2_LRO == 0) if (p1_LRO == 1) R = -1; else L = -1;
- if (p2_LRO == 1) { R = 1; L = p1_LRO; }
-
- // calculate intersection point with line for px
- if (p1_LRO == 0)
- {
- if ((p1.m_y < (py + marge)) && (p1.m_y > (py - marge)))
- return ON_POLY;
- else
- Y_intersect = p1.m_y;
- }
- else if (p2_LRO == 0)
- {
- if ((p2.m_y < (py + marge)) && (p2.m_y > (py - marge)))
- return ON_POLY;
- else
- Y_intersect = p2.m_y;
- }
- else //both p2_LRO and p1_LRO not 0
- {
- if ((p1.m_y > (py + marge)) && (p2.m_y > (py + marge)))
- Y_intersect = p1.m_y; //a save value to check later
- else if ((p1.m_y < (py- marge)) && (p2.m_y < (py - marge)))
- Y_intersect = p1.m_y; //a save value to check later
- else //need to calculate intersection
- {
- if (!((p1.m_x == p2.m_x) && (p1.m_y == p2.m_y)))
- {
- wxLine line1(p1,p2);
- line1.CalculateLineParameters();
- Y_intersect = line1.Calculate_Y(px);
- }
- else
- continue;
- }
- }
- if (Y_intersect > (py + marge))
- {
- R_tot += R;
- L_tot += L;
- }
- else if ((Y_intersect <= (py + marge)) && (Y_intersect >= (py - marge)))
- {
- return ON_POLY;
- }
- }
- }
-
- // geef het juiste resultaat terug
- if (R_tot == 0)
- if (L_tot == 0) return OUTSIDE_POLY;
- else return ON_POLY;
- else
- if (L_tot == 0) return ON_POLY;
- else return INSIDE_POLY;
-}
-
-//----------------------------------------------------------------------------
-// wxCanvasPolylineL
-//----------------------------------------------------------------------------
-
-wxCanvasPolylineL::wxCanvasPolylineL( wxList* points, bool spline )
- : wxCanvasObject()
-{
- m_lpoints = points;
- m_pen = *wxBLACK_PEN;
- m_spline=spline;
- if (m_spline)
- ConvertSplinedPolyline(m_lpoints, 10);
- CalcBoundingBox();
-}
-
-wxCanvasPolylineL::~wxCanvasPolylineL()
-{
- m_lpoints->DeleteContents(TRUE);
- delete m_lpoints;
-}
-
-double wxCanvasPolylineL::GetPosX()
-{
- wxNode *node = m_lpoints->GetFirst();
- wxPoint2DDouble* point = (wxPoint2DDouble*)node->Data();
- return point->m_x;
-}
-
-double wxCanvasPolylineL::GetPosY()
-{
- wxNode *node = m_lpoints->GetFirst();
- wxPoint2DDouble* point = (wxPoint2DDouble*)node->Data();
- return point->m_y;
-}
-
-void wxCanvasPolylineL::SetPosXY( double x, double y )
-{
- wxNode *node = m_lpoints->GetFirst();
- wxPoint2DDouble* point = (wxPoint2DDouble*)node->Data();
- double xo=point->m_x;
- double yo=point->m_y;
- while (node)
- {
- point = (wxPoint2DDouble*)node->Data();
- point->m_x = point->m_x + x-xo;
- point->m_y = point->m_y + y-yo;
- node = node->GetNext();
- }
- CalcBoundingBox();
-}
-
-void wxCanvasPolylineL::TransLate( double x, double y )
-{
- wxNode *node = m_lpoints->GetFirst();
- while (node)
- {
- wxPoint2DDouble* point = (wxPoint2DDouble*)node->Data();
- point->m_x += x;
- point->m_y += y;
- node = node->GetNext();
- }
- CalcBoundingBox();
-}
-
-void wxCanvasPolylineL::CalcBoundingBox()
-{
- m_bbox.SetValid(FALSE);
-
- wxNode *node = m_lpoints->GetFirst();
- while (node)
- {
- wxPoint2DDouble* point = (wxPoint2DDouble*)node->Data();
- m_bbox.Expand( point->m_x,point->m_y);
- node = node->GetNext();
- }
-
- //include the pen width also
- m_bbox.EnLarge(m_pen.GetWidth());
-}
-
-void wxCanvasPolylineL::Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height )
-{
- if (!m_visible) return;
-
- int start_y = clip_y;
- int end_y = clip_y+clip_height;
-
- int start_x = clip_x;
- int end_x = clip_x+clip_width;
-
-#if IMAGE_CANVAS
-#else
- int n=m_lpoints->GetCount();
- wxPoint *cpoints = new wxPoint[n];
-
- wxNode *node = m_lpoints->GetFirst();
- int i=0;
- while (node)
- {
- wxPoint2DDouble* point = (wxPoint2DDouble*)node->Data();
- double x1;
- double y1;
- //transform to absolute
- cworld->TransformPoint( point->m_x, point->m_y, x1, y1 );
- //transform to device
- cpoints[i].x = m_admin->LogicalToDeviceX(x1);
- cpoints[i].y = m_admin->LogicalToDeviceY(y1);
-
- node = node->GetNext();
- i++;
- }
-
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetClippingRegion(start_x,start_y,end_x-start_x,end_y-start_y);
- int pw=m_pen.GetWidth();
- m_pen.SetWidth(m_admin->LogicalToDeviceXRel(pw));
- dc->SetPen(m_pen);
- dc->DrawLines(n, cpoints, 0,0);
- delete [] cpoints;
- dc->SetPen(wxNullPen);
- dc->DestroyClippingRegion();
- m_pen.SetWidth(pw);
-#endif
-}
-
-void wxCanvasPolylineL::WriteSVG( wxTextOutputStream &stream )
-{
-}
-
-wxCanvasObject* wxCanvasPolylineL::IsHitWorld( double x, double y, double margin )
-{
- if ((x >= m_bbox.GetMinX()-margin) &&
- (x <= m_bbox.GetMaxX()+margin) &&
- (y >= m_bbox.GetMinY()-margin) &&
- (y <= m_bbox.GetMaxY()+margin)
- )
- {
- wxPoint2DDouble P=wxPoint2DDouble(x,y);
- if (PointOnPolyline(P,m_pen.GetWidth()/2+margin))
- return this;
- else
- return (wxCanvasObject*) NULL;
- }
- return (wxCanvasObject*) NULL;
-}
-
-bool wxCanvasPolylineL::PointOnPolyline(const wxPoint2DDouble& P, double margin)
-{
- bool result = FALSE;
- double distance;
- wxPoint2DDouble p1,p2;
-
- wxNode *node = m_lpoints->GetFirst();
- p2 = *(wxPoint2DDouble*)node->Data();
- while (node && !result)
- {
- p1=p2;
- node=node->GetNext();
- if (!node) break;
- p2 = *(wxPoint2DDouble*)node->Data();
-
- if (margin > sqrt(pow(p1.m_x-P.m_x,2)+pow(p1.m_y-P.m_y,2)))
- result=TRUE;
- else if (!((p1.m_x == p2.m_x) && (p1.m_y == p2.m_y)))
- {
- wxLine line1(p1,p2);
- if (line1.PointInLine(P,distance,margin) == R_IN_AREA)
- result=TRUE;
- }
- }
-
- return result;
-}
-
-//----------------------------------------------------------------------------
-// wxCanvasPolygon
-//----------------------------------------------------------------------------
-
-wxCanvasPolygonL::wxCanvasPolygonL( wxList* points, bool spline )
- : wxCanvasObject()
-{
- m_lpoints = points;
- m_brush = *wxBLACK_BRUSH;
- m_pen = *wxTRANSPARENT_PEN;
- m_spline=spline;
- m_textfg=*wxBLACK;
- m_textbg=*wxWHITE;
- m_transp=FALSE;
-
- if (m_spline)
- ConvertSplinedPolyline(m_lpoints, 10);
- CalcBoundingBox();
-}
-
-wxCanvasPolygonL::~wxCanvasPolygonL()
-{
- m_lpoints->DeleteContents(TRUE);
- delete m_lpoints;
-}
-
-double wxCanvasPolygonL::GetPosX()
-{
- wxNode *node = m_lpoints->GetFirst();
- wxPoint2DDouble* point = (wxPoint2DDouble*)node->Data();
- return point->m_x;
-}
-
-double wxCanvasPolygonL::GetPosY()
-{
- wxNode *node = m_lpoints->GetFirst();
- wxPoint2DDouble* point = (wxPoint2DDouble*)node->Data();
- return point->m_y;
-}
-
-void wxCanvasPolygonL::SetPosXY( double x, double y )
-{
- wxNode *node = m_lpoints->GetFirst();
- wxPoint2DDouble* point = (wxPoint2DDouble*)node->Data();
- double xo=point->m_x;
- double yo=point->m_y;
- while (node)
- {
- point = (wxPoint2DDouble*)node->Data();
- point->m_x = point->m_x + x-xo;
- point->m_y = point->m_y + y-yo;
- node = node->GetNext();
- }
- CalcBoundingBox();
-}
-
-void wxCanvasPolygonL::TransLate( double x, double y )
-{
- wxNode *node = m_lpoints->GetFirst();
- while (node)
- {
- wxPoint2DDouble* point = (wxPoint2DDouble*)node->Data();
- point->m_x += x;
- point->m_y += y;
- node = node->GetNext();
- }
- CalcBoundingBox();
-}
-
-void wxCanvasPolygonL::CalcBoundingBox()
-{
-
- m_bbox.SetValid(FALSE);
-
- wxNode *node = m_lpoints->GetFirst();
- while (node)
- {
- wxPoint2DDouble* point = (wxPoint2DDouble*)node->Data();
- m_bbox.Expand( point->m_x,point->m_y);
- node = node->GetNext();
- }
-
- //include the pen width also
- m_bbox.EnLarge(m_pen.GetWidth());
-}
-
-void wxCanvasPolygonL::Render(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height )
-{
- if (!m_visible) return;
-
- int start_y = clip_y;
- int end_y = clip_y+clip_height;
-
- int start_x = clip_x;
- int end_x = clip_x+clip_width;
-
-#if IMAGE_CANVAS
-#else
- int n=m_lpoints->GetCount();
- wxPoint *cpoints = new wxPoint[n];
-
- wxNode *node = m_lpoints->GetFirst();
- int i=0;
- while (node)
- {
- wxPoint2DDouble* point = (wxPoint2DDouble*)node->Data();
- double x1;
- double y1;
- //transform to absolute
- cworld->TransformPoint( point->m_x, point->m_y, x1, y1 );
- //transform to device
- cpoints[i].x = m_admin->LogicalToDeviceX(x1);
- cpoints[i].y = m_admin->LogicalToDeviceY(y1);
-
- node = node->GetNext();
- i++;
- }
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetClippingRegion(start_x,start_y,end_x-start_x,end_y-start_y);
- dc->SetBrush(m_brush);
- int pw=m_pen.GetWidth();
- m_pen.SetWidth(m_admin->LogicalToDeviceXRel(pw));
- if ( m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE && m_transp)
- {
- //draw a transparent polygon
- //leaf the pen not transparent, which i prefer
- dc->SetPen( wxPen( *wxWHITE,m_admin->LogicalToDeviceXRel(pw), wxSOLID) );
- dc->SetTextForeground(*wxBLACK);
- dc->SetTextBackground(*wxWHITE);
- dc->SetLogicalFunction(wxAND_INVERT);
- // BLACK OUT the opaque pixels and leave the rest as is
- dc->DrawPolygon(n, cpoints, 0,0,wxWINDING_RULE);
- // Set background and foreground colors for fill pattern
- //the previous blacked out pixels are now merged with the layer color
- //while the non blacked out pixels stay as they are.
- dc->SetTextForeground(*wxBLACK);
- //now define what will be the color of the fillpattern parts that are not transparent
- dc->SetTextBackground(m_textfg);
- dc->SetLogicalFunction(wxOR);
- //don't understand how but the outline is also depending on logicalfunction
- dc->SetPen(m_pen);
- dc->DrawPolygon(n, cpoints, 0,0,wxWINDING_RULE);
- dc->SetLogicalFunction(wxCOPY);
- }
- else
- {
- dc->SetPen(m_pen);
- dc->SetTextForeground(m_textfg);
- dc->SetTextBackground(m_textbg);
- dc->DrawPolygon(n, cpoints, 0,0,wxWINDING_RULE);
- }
- delete [] cpoints;
- dc->SetBrush(wxNullBrush);
- dc->SetPen(wxNullPen);
- dc->DestroyClippingRegion();
- m_pen.SetWidth(pw);
-#endif
-}
-
-void wxCanvasPolygonL::WriteSVG( wxTextOutputStream &stream )
-{
-}
-
-static void GetLRO(const wxPoint2DDouble& P, const wxPoint2DDouble& p1, const wxPoint2DDouble& p2, int &LRO1, int &LRO2,const double marge)
-{
- if (p1.m_x > (P.m_x + marge)) LRO1 = -1; // beginnode is right of P
- else
- if (p1.m_x < (P.m_x - marge)) LRO1 = 1; // beginnode is left of P
- else LRO1 = 0; // beginnode is on vertical line through P
-
- if (p2.m_x > (P.m_x + marge)) LRO2 = -1; // endnode is right of P
- else
- if (p2.m_x < (P.m_x - marge)) LRO2 = 1; // endnode is left of P
- else LRO2 = 0; // endnode is on vertical line through P
-}
-
-wxCanvasObject* wxCanvasPolygonL::IsHitWorld( double x, double y, double margin )
-{
- if ((x >= m_bbox.GetMinX()-margin) &&
- (x <= m_bbox.GetMaxX()+margin) &&
- (y >= m_bbox.GetMinY()-margin) &&
- (y <= m_bbox.GetMaxY()+margin)
- )
- {
- wxPoint2DDouble P=wxPoint2DDouble(x,y);
- INOUTPOLY io=PointInPolygon(P,m_pen.GetWidth()/2 + margin);
- if (io == OUTSIDE_POLY)
- return (wxCanvasObject*) NULL;
- else
- return this;
- }
- return (wxCanvasObject*) NULL;
-}
-
-INOUTPOLY wxCanvasPolygonL::PointInPolygon(const wxPoint2DDouble& P, double marge)
-{
- int R_tot = 0, L_tot = 0;
- int p1_LRO, p2_LRO;
- double px = P.m_x, py = P.m_y;
- double Y_intersect;
- wxPoint2DDouble p1,p2;
-
- //iterate across points until we are sure that the given point is in or out
- wxNode *node = m_lpoints->GetFirst();
-
- while (node)
- {
- p1 = *(wxPoint2DDouble*)node->Data();
- if (m_lpoints->GetLast() == node)
- {
- p2 = *(wxPoint2DDouble*)m_lpoints->GetFirst();
- }
- else
- {
- p2 = *(wxPoint2DDouble*)node->GetNext()->Data();
- }
-
- //more accurate
- GetLRO(P,p1,p2,p1_LRO,p2_LRO,marge/10);
- if (p1_LRO != p2_LRO)
- {
- int L = 0, R = 0;
- if (p2_LRO == -1) { R = -p1_LRO; L = 1; }
- if (p2_LRO == 0) if (p1_LRO == 1) R = -1; else L = -1;
- if (p2_LRO == 1) { R = 1; L = p1_LRO; }
-
- // calculate intersection point with line for px
- if (p1_LRO == 0)
- {
- if ((p1.m_y < (py + marge)) && (p1.m_y > (py - marge)))
- return ON_POLY;
- else
- Y_intersect = p1.m_y;
- }
- else if (p2_LRO == 0)
- {
- if ((p2.m_y < (py + marge)) && (p2.m_y > (py - marge)))
- return ON_POLY;
- else
- Y_intersect = p2.m_y;
- }
- else //both p2_LRO and p1_LRO not 0
- {
- if ((p1.m_y > (py + marge)) && (p2.m_y > (py + marge)))
- Y_intersect = p1.m_y; //a save value to check later
- else if ((p1.m_y < (py- marge)) && (p2.m_y < (py - marge)))
- Y_intersect = p1.m_y; //a save value to check later
- else //need to calculate intersection
- {
- if (!((p1.m_x == p2.m_x) && (p1.m_y == p2.m_y)))
- {
- wxLine line1(p1,p2);
- line1.CalculateLineParameters();
- Y_intersect = line1.Calculate_Y(px);
- }
- else
- continue;
- }
- }
- if (Y_intersect > (py + marge))
- {
- R_tot += R;
- L_tot += L;
- }
- else if ((Y_intersect <= (py + marge)) && (Y_intersect >= (py - marge)))
- {
- return ON_POLY;
- }
- }
- node=node->Next();
- }
-
- // geef het juiste resultaat terug
- if (R_tot == 0)
- if (L_tot == 0) return OUTSIDE_POLY;
- else return ON_POLY;
- else
- if (L_tot == 0) return ON_POLY;
- else return INSIDE_POLY;
-}
-
-// ---------------------------------------------------------------------------
-// spline drawing code
-// ---------------------------------------------------------------------------
-
-static void gds_quadratic_spline(wxList *org,double a1, double b1, double a2, double b2,
- double a3, double b3, double a4, double b4,double aber);
-static void gds_clear_stack();
-static int gds_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3,
- double *y3, double *x4, double *y4);
-static void gds_spline_push(double x1, double y1, double x2, double y2, double x3, double y3,
- double x4, double y4);
-
-void ConvertSplinedPolygon(int& n, wxPoint2DDouble* points[], double Aber)
-{
- wxList h;
- int i;
- for (i = 0; i < n; i++)
- {
- h.Append((wxObject*) new wxPoint2DDouble((*points)[i].m_x, (*points)[i].m_y));
- }
- delete *points;
-
- ConvertSplinedPolygon(&h, Aber);
-
- n=h.GetCount();
- *points = new wxPoint2DDouble[n];
- wxNode* node=h.GetFirst();
- for (i = 0; i < n; i++)
- {
- wxNode* hh= node;
- node = node->GetNext();
- (*points)[i].m_x=((wxPoint2DDouble*) hh->GetData())->m_x;
- (*points)[i].m_y=((wxPoint2DDouble*) hh->GetData())->m_y;
- delete (wxPoint2DDouble*) hh->GetData();
- h.DeleteNode(hh);
- }
-}
-
-void ConvertSplinedPolygon(wxList* list, double Aber)
-{
- wxPoint2DDouble* point;
- double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
- double x1, y1, x2, y2;
-
- if (list->GetCount() <2)
- return;
-
- wxNode* iter=list->GetLast();
- x1 = ((wxPoint2DDouble*)iter->Data())->m_x;
- y1 = ((wxPoint2DDouble*)iter->Data())->m_y;
-
- iter=list->GetFirst();
- x2 = ((wxPoint2DDouble*)iter->Data())->m_x;
- y2 = ((wxPoint2DDouble*)iter->Data())->m_y;
-
- point = new wxPoint2DDouble(x2,y2);
- list->Append((wxObject*)point);
-
- cx1 = (x1 + x2) / 2.0;
- cy1 = (y1 + y2) / 2.0;
- cx2 = (cx1 + x2) / 2.0;
- cy2 = (cy1 + y2) / 2.0;
-
- delete (wxPoint2DDouble*) iter->Data();
- delete iter;
- iter=list->GetFirst();
- x1 = ((wxPoint2DDouble*)iter->Data())->m_x;
- y1 = ((wxPoint2DDouble*)iter->Data())->m_y;
- point = new wxPoint2DDouble(x1,y1);
- list->Append((wxObject*)point);
-
- int i=1;
- int count=list->GetCount();
- while (i < count)
- {
- x1 = x2;
- y1 = y2;
- x2 = ((wxPoint2DDouble*)iter->Data())->m_x;
- y2 = ((wxPoint2DDouble*)iter->Data())->m_y;
- cx4 = (x1 + x2) / 2.0;
- cy4 = (y1 + y2) / 2.0;
- cx3 = (x1 + cx4) / 2.0;
- cy3 = (y1 + cy4) / 2.0;
-
- gds_quadratic_spline(list,cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4,Aber);
-
- cx1 = cx4;
- cy1 = cy4;
- cx2 = (cx1 + x2) / 2.0;
- cy2 = (cy1 + y2) / 2.0;
- delete (wxPoint2DDouble*)iter->Data();
- delete iter;
- iter=list->GetFirst();
- i++;
- }
-
- iter=list->GetFirst();
- delete (wxPoint2DDouble*)iter->Data();
- delete iter;
-}
-
-void ConvertSplinedPolyline(wxList* list,double Aber)
-{
- double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
- double x1, y1, x2, y2;
-
-
- if (list->GetCount() <2)
- return;
-
-
-
- wxNode* iter=list->GetFirst();
-
- x1 = ((wxPoint2DDouble*)iter->Data())->m_x;
- y1 = ((wxPoint2DDouble*)iter->Data())->m_y;
-
- delete (wxPoint2DDouble*)iter->Data();
- delete iter;
- iter=list->GetFirst();
- x2 = ((wxPoint2DDouble*)iter->Data())->m_x;
- y2 = ((wxPoint2DDouble*)iter->Data())->m_y;
- cx1 = (x1 + x2) / 2.0;
- cy1 = (y1 + y2) / 2.0;
- cx2 = (cx1 + x2) / 2.0;
- cy2 = (cy1 + y2) / 2.0;
-
- wxPoint2DDouble* point = new wxPoint2DDouble(x1,y1);
- list->Append((wxObject*)point);
-
- delete (wxPoint2DDouble*)iter->Data();
- delete iter;
- iter=list->GetFirst();
-
- int i=1;
- int count=list->GetCount();
- while (i < count)
- {
- x1 = x2;
- y1 = y2;
- x2 = ((wxPoint2DDouble*)iter->Data())->m_x;
- y2 = ((wxPoint2DDouble*)iter->Data())->m_y;
- cx4 = (x1 + x2) / 2.0;
- cy4 = (y1 + y2) / 2.0;
- cx3 = (x1 + cx4) / 2.0;
- cy3 = (y1 + cy4) / 2.0;
-
- gds_quadratic_spline(list,cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4,Aber);
-
- cx1 = cx4;
- cy1 = cy4;
- cx2 = (cx1 + x2) / 2.0;
- cy2 = (cy1 + y2) / 2.0;
- delete (wxPoint2DDouble*)iter->Data();
- delete iter;
- iter=list->GetFirst();
- i++;
- }
-
- point = new wxPoint2DDouble(cx1,cy1);
- list->Append((wxObject*)point);
-
- point = new wxPoint2DDouble(x2,y2);
- list->Append((wxObject*)point);
-}
-
-/********************* CURVES FOR SPLINES *****************************
-
- The following spline drawing routine is from
-
- "An Algorithm for High-Speed Curve Generation"
- by George Merrill Chaikin,
- Computer Graphics and Image Processing, 3, Academic Press,
- 1974, 346-349.
-
- and
-
- "On Chaikin's Algorithm" by R. F. Riesenfeld,
- Computer Graphics and Image Processing, 4, Academic Press,
- 1975, 304-310.
-
-***********************************************************************/
-
-#define half(z1, z2) ((z1+z2)/2.0)
-#define THRESHOLD 5
-
-/* iterative version */
-
-void gds_quadratic_spline(wxList *org,double a1, double b1, double a2, double b2, double a3, double b3, double a4,
- double b4,double Aber)
-{
- register double xmid, ymid;
- double x1, y1, x2, y2, x3, y3, x4, y4;
- wxPoint2DDouble* point;
-
- gds_clear_stack();
- gds_spline_push(a1, b1, a2, b2, a3, b3, a4, b4);
-
- while (gds_spline_pop(&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4))
- {
- xmid = half(x2, x3);
- ymid = half(y2, y3);
- if (fabs(x1 - xmid) < Aber && fabs(y1 - ymid) < Aber &&
- fabs(xmid - x4) < Aber && fabs(ymid - y4) < Aber)
- {
- point = new wxPoint2DDouble(x1,y1);
- org->Append((wxObject*)point);
- point = new wxPoint2DDouble(xmid,ymid);
- org->Append((wxObject*)point);
- } else {
- gds_spline_push(xmid, ymid, half(xmid, x3), half(ymid, y3),
- half(x3, x4), half(y3, y4), x4, y4);
- gds_spline_push(x1, y1, half(x1, x2), half(y1, y2),
- half(x2, xmid), half(y2, ymid), xmid, ymid);
- }
- }
-}
-
-
-/* utilities used by spline drawing routines */
-
-
-typedef struct gds_spline_stack_struct {
- double x1, y1, x2, y2, x3, y3, x4, y4;
-}
-Stack;
-
-#define SPLINE_STACK_DEPTH 20
-static Stack gds_spline_stack[SPLINE_STACK_DEPTH];
-static Stack *gds_stack_top;
-static int gds_stack_count;
-
-static void gds_clear_stack()
-{
- gds_stack_top = gds_spline_stack;
- gds_stack_count = 0;
-}
-
-static void gds_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
-{
- gds_stack_top->x1 = x1;
- gds_stack_top->y1 = y1;
- gds_stack_top->x2 = x2;
- gds_stack_top->y2 = y2;
- gds_stack_top->x3 = x3;
- gds_stack_top->y3 = y3;
- gds_stack_top->x4 = x4;
- gds_stack_top->y4 = y4;
- gds_stack_top++;
- gds_stack_count++;
-}
-
-int gds_spline_pop(double *x1, double *y1, double *x2, double *y2,
- double *x3, double *y3, double *x4, double *y4)
-{
- if (gds_stack_count == 0)
- return (0);
- gds_stack_top--;
- gds_stack_count--;
- *x1 = gds_stack_top->x1;
- *y1 = gds_stack_top->y1;
- *x2 = gds_stack_top->x2;
- *y2 = gds_stack_top->y2;
- *x3 = gds_stack_top->x3;
- *y3 = gds_stack_top->y3;
- *x4 = gds_stack_top->x4;
- *y4 = gds_stack_top->y4;
- return (1);
-}
-
-void wxAET::CalculateLineParameters( const wxPoint2DDouble& p1 , const wxPoint2DDouble& p2 )
-{
- double A = p2.m_y - p1.m_y; //A (y2-y1)
- if (A == 0)
- {
- m_horizontal=TRUE;
- m_BdivA=0;
- m_CdivA=0;
- }
- else
- {
- m_horizontal=FALSE;
- m_BdivA= (p1.m_x - p2.m_x)/A; //B (x1-x2)
- //normalize
- m_CdivA= ((p2.m_x*p1.m_y) - (p1.m_x*p2.m_y)) /A ;
- }
-}
-
-void wxAET::CalculateXs( double y )
-{
- m_xs= -m_BdivA * y - m_CdivA;
-}
-
-//use by polygon filling
-//moves the scanline up
-//index is the index of the point where the search begins
-//direction is +1 or -1 and indicates if the segment ascends or decends
-bool wxCanvasPolygon::MoveUp( double horline, int& index, int direction)
-{
- int walk = (index + direction + m_n) % m_n;
- while ( m_points[walk].m_y < horline )
- {
- if (m_points[walk].m_y < m_points[index].m_y )
- return FALSE;
- else
- {
- //modify index
- index=walk;
- walk = (index + direction + m_n) % m_n;
- }
- }
- return TRUE;
-}
-
-//a crictical point is a point between a decending and a ascending segment
-//collect those points for filling later
-void wxCanvasPolygon::DetectCriticalPoints()
-{
- //candidate for critical point
- //true if Y is getting lower, unchanged i Y is unchanged
- //and if Y becomes higher and candidate was true: it is a critical point
- bool candidate = FALSE;
- int i,j;
-
- for ( i=0; i < m_n; i++)
- {
- //j next point
- j= (i+1) % m_n;
-
- //check if Y is smaller
- if (m_points[i].m_y > m_points[j].m_y)
- //we have a candidate
- candidate=TRUE;
- else if ( (m_points[i].m_y < m_points[j].m_y) && candidate)
- { //this is a critical point put in list
- bool inserted=FALSE;
- wxNode *node = m_CRlist.GetFirst();
- while (node)
- {
- //sorted on smallest Y value
- int* ind=(int*) node->GetData();
- if (m_points[*ind].m_y > m_points[i].m_y)
- {
- m_CRlist.Insert(node,(wxObject*) new int(i));
- inserted = TRUE;
- break;
- }
- node = node->GetNext();
- }
- if (!inserted)
- m_CRlist.Append((wxObject*) new int(i));
- candidate = FALSE;
- }
- }
- if (candidate)
- {
- for ( i=0; i < m_n; i++)
- {
- //j next point
- j= (i+1) % m_n;
-
- //check if Y is smaller
- if (m_points[i].m_y > m_points[j].m_y)
- //we have a candidate
- candidate=TRUE;
- else if ( (m_points[i].m_y < m_points[j].m_y) && candidate)
- { //this is a critical point put in list
- bool inserted=FALSE;
- wxNode *node = m_CRlist.GetFirst();
- while (node)
- {
- //sorted on smallest Y value
- int* ind=(int*) node->GetData();
- if (m_points[*ind].m_y > m_points[i].m_y)
- {
- m_CRlist.Insert(node,(wxObject*) new int(i));
- inserted = TRUE;
- break;
- }
- node = node->GetNext();
- }
- if (!inserted)
- m_CRlist.Append((wxObject*) new int(i));
- candidate = FALSE;
- }
- }
- }
-}
-
-
-void wxCanvasPolygon::FillPolygon(wxTransformMatrix* cworld, int clip_x, int clip_y, int clip_width, int clip_height )
-{
-#if IMAGE_CANVAS
-#else
- int index;
- //how much is on pixel in world coordinates
-
- double scalefactor;
- if (m_gdistance)
- scalefactor=m_gdistance;
- else
- //abs here needed if yaxis is going up (always scan in world coordinates UP)
- scalefactor=fabs(m_admin->DeviceToLogicalYRel(1)); //1 pixel height
-
- wxDC *dc = m_admin->GetActive()->GetDC();
- dc->SetClippingRegion( clip_x, clip_y, clip_width, clip_height );
- wxPen gradientpen=m_gpen;
-
- int dred = m_textbg.Red()-m_textfg.Red();
- int dgreen = m_textbg.Green()-m_textfg.Green();
- int dblue = m_textbg.Blue()-m_textfg.Blue();
-
- //total number of lines to go from m_textbg to m_textfg
- //gives the following number of steps for the gradient color
- int stepcol = (int) (m_bbox.GetHeight()/scalefactor);
-
- DetectCriticalPoints();
-
- double min;
- double max;
- if (cworld->IsIdentity())
- {
- //TODO do something with clipping region (inverse transform?)
- //the next does not work, i don't know why
- //min = wxMin (m_admin->DeviceToLogicalY(clip_y),m_admin->DeviceToLogicalY(clip_y+clip_height));
- //max = wxMax (m_admin->DeviceToLogicalY(clip_y),m_admin->DeviceToLogicalY(clip_y+clip_height));
- min= m_bbox.GetMinY();
- max= m_bbox.GetMaxY();
- }
- else
- {
- min= m_bbox.GetMinY();
- max= m_bbox.GetMaxY();
- }
-
- int curcol = (int)( (min - m_bbox.GetMinY())/scalefactor );
-
- double i;
- for ( i = min; i < max; i+=scalefactor)
- {
- wxNode *node = m_AETlist.GetFirst();
- int count= m_AETlist.GetCount();
- while (count > 0)
- {
- wxAET* ele = ((wxAET*)node->GetData());
- index= ele->m_index;
- int direction = ele->m_direction;
- if (!MoveUp(i,index,direction))
- {
- wxNode* h = node;
- //remove this node
- node = node->GetNext();
- m_AETlist.DeleteNode(h);
- }
- else
- {
- if (ele->m_index != index)
- {
- ele->m_index=index;
- int h = (index + direction + m_n) % m_n;
- ele->CalculateLineParameters(m_points[h],m_points[index]);
- }
- if (ele->m_horizontal)
- ele->m_xs=m_points[index].m_x;
- else
- ele->CalculateXs(i);
- node = node->GetNext();
- }
- count--;
- }
-
- node = m_CRlist.GetFirst();
- while (m_CRlist.GetCount() && m_points[*((int*)node->GetData())].m_y <=i )
- {
- int DI;
- for ( DI = -1; DI <=1 ; DI+=2)
- {
- index=*((int*)node->GetData());
- if (MoveUp(i,index,DI))
- {
- wxAET* ele = new wxAET();
- ele->m_index=index;
- ele->m_direction=DI;
- int h = (index + DI + m_n) % m_n;
- ele->CalculateLineParameters(m_points[h],m_points[index]);
- if (ele->m_horizontal)
- ele->m_xs=m_points[index].m_x;
- else
- ele->CalculateXs(i);
-
- //insert in sorted order od m_xs
- bool inserted=FALSE;
- wxNode *node2 = m_AETlist.GetFirst();
- while (node2)
- {
- //sorted on smallest xs value
- if (ele->m_xs < ((wxAET*)node2->GetData())->m_xs)
- {
- m_AETlist.Insert(node2,(wxObject*) ele);
- inserted = TRUE;
- break;
- }
- node2 = node2->GetNext();
- }
- if (!inserted)
- m_AETlist.Append((wxObject*)ele);
- }
- }
-
- wxNode* h= node;
- node = node->GetNext();
- m_CRlist.DeleteNode(h);
- }
-
- curcol++;
- wxColour gradcol(m_textbg.Red()+dred*curcol/stepcol,
- m_textbg.Green()+dgreen*curcol/stepcol,
- m_textbg.Blue()+dblue*curcol/stepcol);
- gradientpen.SetColour(gradcol);
-
- //m_AETlist must be sorted in m_xs at this moment
- //now draw all the line parts on one horizontal scanline (Winding Rule)
- int out= 0;
- node = m_AETlist.GetFirst();
- while (node)
- {
- wxAET* ele = ((wxAET*)node->GetData());
- out+=ele->m_direction;
- if (out != 0)
- {
- double x1=ele->m_xs;
- node = node->GetNext();
- ele = ((wxAET*)node->GetData());
- double x2=ele->m_xs;
- dc->SetPen( gradientpen );
- double wx1,wy1,wx2,wy2;
- cworld->TransformPoint( x1, i, wx1, wy1 );
- cworld->TransformPoint( x2, i, wx2, wy2 );
- int dx1,dy1,dx2,dy2;
- dx1 = m_admin->LogicalToDeviceX( wx1 );
- dy1 = m_admin->LogicalToDeviceY( wy1 );
- dx2 = m_admin->LogicalToDeviceX( wx2 );
- dy2 = m_admin->LogicalToDeviceY( wy2 );
-
- //TODO KKK need real line clipping here since line can be rotated.
- if (0 && cworld->IsIdentity())
- {
- if (dx1 < clip_x) dx1=clip_x;
- if (dx2 > clip_x + clip_width) dx2=clip_x + clip_width;
- if ((dy1 > clip_y) && dy1 < clip_y + clip_height)
- dc->DrawLine( dx1, dy1, dx2, dy2 );
- }
- else
- {
- dc->DrawLine( dx1, dy1, dx2, dy2 );
- }
-
- }
- else
- node = node->GetNext();
- }
- }
-
- dc->DestroyClippingRegion();
-#endif
-}
-
-
-
-
-