Various bug fixes to OGL; wxStripExtension prototype added to filefn.h

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@437 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1998-08-05 07:13:08 +00:00
parent 7a4b9130e3
commit 2bb0cd285a
19 changed files with 539 additions and 426 deletions

View File

@@ -10,8 +10,7 @@ No parent class.
\wxheading{See also} \wxheading{See also}
\overview{Overview}{wxclassinfooverview}\\ \helpref{Overview}{wxclassinfooverview}, \helpref{wxObject}{wxobject}
\helpref{wxObject}{wxobject}
\latexignore{\rtfignore{\wxheading{Members}}} \latexignore{\rtfignore{\wxheading{Members}}}

View File

@@ -73,6 +73,7 @@ void WXDLLEXPORT wxUnix2DosFilename(char *s);
// Strip the extension, in situ // Strip the extension, in situ
void WXDLLEXPORT wxStripExtension(char *buffer); void WXDLLEXPORT wxStripExtension(char *buffer);
void WXDLLEXPORT wxStripExtension(wxString& buffer);
// Get a temporary filename, opening and closing the file. // Get a temporary filename, opening and closing the file.
char* WXDLLEXPORT wxGetTempFileName(const wxString& prefix, char *buf = NULL); char* WXDLLEXPORT wxGetTempFileName(const wxString& prefix, char *buf = NULL);

View File

@@ -102,6 +102,7 @@ wxDocMDIChildFrame::wxDocMDIChildFrame(wxDocument *doc, wxView *view, wxMDIParen
wxDocMDIChildFrame::~wxDocMDIChildFrame(void) wxDocMDIChildFrame::~wxDocMDIChildFrame(void)
{ {
m_childView = NULL;
} }
// Extend event processing to search the view's event table // Extend event processing to search the view's event table

View File

@@ -196,16 +196,28 @@ bool wxDocument::SaveAs(void)
char *tmp = wxFileSelector("Save as", docTemplate->GetDirectory(), GetFilename(), char *tmp = wxFileSelector("Save as", docTemplate->GetDirectory(), GetFilename(),
docTemplate->GetDefaultExtension(), docTemplate->GetFileFilter(), docTemplate->GetDefaultExtension(), docTemplate->GetFileFilter(),
0, GetDocumentWindow()); wxSAVE|wxOVERWRITE_PROMPT, GetDocumentWindow());
if (!tmp) if (!tmp)
return FALSE; return FALSE;
else else
{ {
SetFilename(tmp); wxString fileName(tmp);
SetTitle(wxFileNameFromPath(tmp)); wxString path("");
wxString name("");
wxString ext("");
wxSplitPath(fileName, & path, & name, & ext);
if (ext.IsEmpty() || ext == "")
{
fileName += ".";
fileName += docTemplate->GetDefaultExtension();
}
SetFilename(fileName);
SetTitle(wxFileNameFromPath(fileName));
GetDocumentManager()->AddFileToHistory(tmp); GetDocumentManager()->AddFileToHistory(fileName);
// Notify the views that the filename has changed // Notify the views that the filename has changed
wxNode *node = m_documentViews.First(); wxNode *node = m_documentViews.First();

View File

@@ -81,6 +81,22 @@ wxShapeEvtHandler::~wxShapeEvtHandler()
{ {
} }
// Creates a copy of this event handler.
wxShapeEvtHandler* wxShapeEvtHandler::CreateNewCopy()
{
wxShapeEvtHandler* newObject = (wxShapeEvtHandler*) GetClassInfo()->CreateObject();
wxASSERT( (newObject != NULL) );
wxASSERT( (newObject->IsKindOf(CLASSINFO(wxShapeEvtHandler))) );
newObject->m_previousHandler = newObject;
CopyData(*newObject);
return newObject;
}
void wxShapeEvtHandler::OnDelete() void wxShapeEvtHandler::OnDelete()
{ {
if (this != GetShape()) if (this != GetShape())
@@ -197,6 +213,26 @@ void wxShapeEvtHandler::OnEndDragRight(float x, float y, int keys, int attachmen
m_previousHandler->OnEndDragRight(x, y, keys, attachment); m_previousHandler->OnEndDragRight(x, y, keys, attachment);
} }
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
void wxShapeEvtHandler::OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnSizingDragLeft(pt, draw, x, y, keys, attachment);
}
void wxShapeEvtHandler::OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnSizingBeginDragLeft(pt, x, y, keys, attachment);
}
void wxShapeEvtHandler::OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnSizingEndDragLeft(pt, x, y, keys, attachment);
}
void wxShapeEvtHandler::OnDrawOutline(wxDC& dc, float x, float y, float w, float h) void wxShapeEvtHandler::OnDrawOutline(wxDC& dc, float x, float y, float w, float h)
{ {
if (m_previousHandler) if (m_previousHandler)
@@ -220,7 +256,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxShape, wxShapeEvtHandler)
wxShape::wxShape(wxShapeCanvas *can) wxShape::wxShape(wxShapeCanvas *can)
{ {
m_eventHandler = this; m_eventHandler = this;
SetHandlerShape(this); SetShape(this);
m_id = 0; m_id = 0;
m_formatted = FALSE; m_formatted = FALSE;
m_canvas = can; m_canvas = can;
@@ -1876,7 +1912,7 @@ void wxShape::ReadRegions(wxExpr *clause)
m_regionProportionX = propXExpr->RealValue(); m_regionProportionX = propXExpr->RealValue();
m_regionProportionY = propYExpr->RealValue(); m_regionProportionY = propYExpr->RealValue();
formatMode = (formatExpr->IntegerValue() != 0); formatMode = (int) formatExpr->IntegerValue();
fontSize = (int)sizeExpr->IntegerValue(); fontSize = (int)sizeExpr->IntegerValue();
fontFamily = (int)familyExpr->IntegerValue(); fontFamily = (int)familyExpr->IntegerValue();
fontStyle = (int)styleExpr->IntegerValue(); fontStyle = (int)styleExpr->IntegerValue();
@@ -2056,16 +2092,48 @@ void wxShape::Copy(wxShape& copy)
} }
// Create and return a new, fully copied object. // Create and return a new, fully copied object.
wxShape *wxShape::CreateNewCopy(wxShapeCanvas *theCanvas) wxShape *wxShape::CreateNewCopy(bool resetMapping, bool recompute)
{ {
wxObjectCopyMapping.Clear(); if (resetMapping)
wxShape *newObject = PrivateCopy(); wxObjectCopyMapping.Clear();
if (theCanvas)
newObject->AddToCanvas(theCanvas); wxShape* newObject = (wxShape*) GetClassInfo()->CreateObject();
newObject->Recompute();
wxASSERT( (newObject != NULL) );
wxASSERT( (newObject->IsKindOf(CLASSINFO(wxShape))) );
Copy(*newObject);
if (GetEventHandler() != this)
{
wxShapeEvtHandler* newHandler = GetEventHandler()->CreateNewCopy();
newObject->SetEventHandler(newHandler);
newObject->SetPreviousHandler(newObject);
newHandler->SetPreviousHandler(newHandler);
newHandler->SetShape(newObject);
}
if (recompute)
newObject->Recompute();
return newObject; return newObject;
} }
// Does the copying for this object, including copying event
// handler data if any. Calls the virtual Copy function.
void wxShape::CopyWithHandler(wxShape& copy)
{
Copy(copy);
if (GetEventHandler() != this)
{
wxASSERT( copy.GetEventHandler() != NULL );
wxASSERT( copy.GetEventHandler() != (&copy) );
wxASSERT( GetEventHandler()->GetClassInfo() == copy.GetEventHandler()->GetClassInfo() );
GetEventHandler()->CopyData(* (copy.GetEventHandler()));
}
}
// Default - make 6 control points // Default - make 6 control points
void wxShape::MakeControlPoints() void wxShape::MakeControlPoints()
{ {

View File

@@ -114,9 +114,12 @@ class wxShapeEvtHandler: public wxObject
wxShapeEvtHandler(wxShapeEvtHandler *prev = NULL, wxShape *shape = NULL); wxShapeEvtHandler(wxShapeEvtHandler *prev = NULL, wxShape *shape = NULL);
virtual ~wxShapeEvtHandler(); virtual ~wxShapeEvtHandler();
inline void SetHandlerShape(wxShape *sh) { m_handlerShape = sh; } inline void SetShape(wxShape *sh) { m_handlerShape = sh; }
inline wxShape *GetShape() const { return m_handlerShape; } inline wxShape *GetShape() const { return m_handlerShape; }
inline void SetPreviousHandler(wxShapeEvtHandler* handler) { m_previousHandler = handler; }
inline wxShapeEvtHandler* GetPreviousHandler() const { return m_previousHandler; }
// This is called when the _shape_ is deleted. // This is called when the _shape_ is deleted.
virtual void OnDelete(); virtual void OnDelete();
virtual void OnDraw(wxDC& dc); virtual void OnDraw(wxDC& dc);
@@ -142,9 +145,22 @@ class wxShapeEvtHandler: public wxObject
virtual void OnEraseControlPoints(wxDC& dc); virtual void OnEraseControlPoints(wxDC& dc);
virtual void OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE); virtual void OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys=0, int attachment = 0); // Erase if draw false
virtual void OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
virtual void OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
virtual void OnBeginSize(float WXUNUSED(w), float WXUNUSED(h)) { } virtual void OnBeginSize(float WXUNUSED(w), float WXUNUSED(h)) { }
virtual void OnEndSize(float WXUNUSED(w), float WXUNUSED(h)) { } virtual void OnEndSize(float WXUNUSED(w), float WXUNUSED(h)) { }
// Creates a copy of this event handler.
wxShapeEvtHandler *CreateNewCopy();
// Does the copy - override for new event handlers which might store
// app-specific data.
virtual void CopyData(wxShapeEvtHandler& copy) {};
private: private:
wxShapeEvtHandler* m_previousHandler; wxShapeEvtHandler* m_previousHandler;
wxShape* m_handlerShape; wxShape* m_handlerShape;
@@ -207,6 +223,12 @@ class wxShape: public wxShapeEvtHandler
virtual void OnBeginSize(float WXUNUSED(w), float WXUNUSED(h)) { } virtual void OnBeginSize(float WXUNUSED(w), float WXUNUSED(h)) { }
virtual void OnEndSize(float WXUNUSED(w), float WXUNUSED(h)) { } virtual void OnEndSize(float WXUNUSED(w), float WXUNUSED(h)) { }
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys=0, int attachment = 0); // Erase if draw false
virtual void OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
virtual void OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
virtual void MakeControlPoints(); virtual void MakeControlPoints();
virtual void DeleteControlPoints(wxDC *dc = NULL); virtual void DeleteControlPoints(wxDC *dc = NULL);
virtual void ResetControlPoints(); virtual void ResetControlPoints();
@@ -309,7 +331,7 @@ class wxShape: public wxShapeEvtHandler
virtual void NameRegions(const wxString& parentName = ""); virtual void NameRegions(const wxString& parentName = "");
// Get list of regions // Get list of regions
inline wxList& GetRegions() { return m_regions; } inline wxList& GetRegions() const { return (wxList&) m_regions; }
virtual void AddRegion(wxShapeRegion *region); virtual void AddRegion(wxShapeRegion *region);
@@ -341,10 +363,6 @@ class wxShape: public wxShapeEvtHandler
virtual void ReadRegions(wxExpr *clause); virtual void ReadRegions(wxExpr *clause);
#endif #endif
// Does the WHOLE copy calling PrivateCopy - don't redefine.
// If canvas is non-null, set the canvas too.
wxShape *CreateNewCopy(wxShapeCanvas *theCanvas = NULL);
// Attachment code // Attachment code
virtual bool GetAttachmentPosition(int attachment, float *x, float *y, virtual bool GetAttachmentPosition(int attachment, float *x, float *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL); int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
@@ -369,10 +387,15 @@ class wxShape: public wxShapeEvtHandler
// Returns TRUE if image is a descendant of this image // Returns TRUE if image is a descendant of this image
bool HasDescendant(wxShape *image); bool HasDescendant(wxShape *image);
// Creates a copy of this shape.
wxShape *CreateNewCopy(bool resetMapping = TRUE, bool recompute = TRUE);
// Does the copying for this object // Does the copying for this object
void Copy(wxShape& copy); virtual void Copy(wxShape& copy);
// Returns a new instance, and does the copy for this class. Define for each class.
virtual wxShape *PrivateCopy() = 0; // Does the copying for this object, including copying event
// handler data if any. Calls the virtual Copy function.
void CopyWithHandler(wxShape& copy);
// Rotate about the given axis by the given amount in radians // Rotate about the given axis by the given amount in radians
// (does nothing for most objects) // (does nothing for most objects)
@@ -455,6 +478,12 @@ class wxPolygonShape: public wxShape
void OnDraw(wxDC& dc); void OnDraw(wxDC& dc);
void OnDrawOutline(wxDC& dc, float x, float y, float w, float h); void OnDrawOutline(wxDC& dc, float x, float y, float w, float h);
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys=0, int attachment = 0);
virtual void OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
virtual void OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
// A polygon should have a control point at each vertex, // A polygon should have a control point at each vertex,
// with the option of moving the control points individually // with the option of moving the control points individually
// to change the shape. // to change the shape.
@@ -485,8 +514,7 @@ class wxPolygonShape: public wxShape
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL); int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
bool AttachmentIsValid(int attachment); bool AttachmentIsValid(int attachment);
// Does the copying for this object // Does the copying for this object
void Copy(wxPolygonShape& copy); void Copy(wxShape& copy);
wxShape *PrivateCopy();
inline wxList *GetPoints() { return m_points; } inline wxList *GetPoints() { return m_points; }
@@ -522,8 +550,7 @@ class wxRectangleShape: public wxShape
bool GetAttachmentPosition(int attachment, float *x, float *y, bool GetAttachmentPosition(int attachment, float *x, float *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL); int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
// Does the copying for this object // Does the copying for this object
void Copy(wxRectangleShape& copy); void Copy(wxShape& copy);
wxShape *PrivateCopy();
inline float GetWidth() const { return m_width; } inline float GetWidth() const { return m_width; }
inline float GetHeight() const { return m_height; } inline float GetHeight() const { return m_height; }
@@ -547,8 +574,7 @@ class wxTextShape: public wxRectangleShape
#endif #endif
// Does the copying for this object // Does the copying for this object
void Copy(wxTextShape& copy); void Copy(wxShape& copy);
wxShape *PrivateCopy();
}; };
class wxEllipseShape: public wxShape class wxEllipseShape: public wxShape
@@ -576,8 +602,7 @@ class wxEllipseShape: public wxShape
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL); int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
// Does the copying for this object // Does the copying for this object
void Copy(wxEllipseShape& copy); void Copy(wxShape& copy);
wxShape *PrivateCopy();
inline float GetWidth() const { return m_width; } inline float GetWidth() const { return m_width; }
inline float GetHeight() const { return m_height; } inline float GetHeight() const { return m_height; }
@@ -597,8 +622,7 @@ class wxCircleShape: public wxEllipseShape
float x2, float y2, float x2, float y2,
float *x3, float *y3); float *x3, float *y3);
// Does the copying for this object // Does the copying for this object
void Copy(wxCircleShape& copy); void Copy(wxShape& copy);
wxShape *PrivateCopy();
}; };
#endif #endif

View File

@@ -826,26 +826,30 @@ void wxPolygonShape::ReadPrologAttributes(wxExpr *clause)
} }
#endif #endif
void wxPolygonShape::Copy(wxPolygonShape& copy) void wxPolygonShape::Copy(wxShape& copy)
{ {
wxShape::Copy(copy); wxShape::Copy(copy);
if (copy.m_points) wxASSERT( copy.IsKindOf(CLASSINFO(wxPolygonShape)) );
delete copy.m_points;
copy.m_points = new wxList; wxPolygonShape& polyCopy = (wxPolygonShape&) copy;
if (copy.m_originalPoints) if (polyCopy.m_points)
delete copy.m_originalPoints; delete polyCopy.m_points;
copy.m_originalPoints = new wxList; polyCopy.m_points = new wxList;
if (polyCopy.m_originalPoints)
delete polyCopy.m_originalPoints;
polyCopy.m_originalPoints = new wxList;
wxNode *node = m_points->First(); wxNode *node = m_points->First();
while (node) while (node)
{ {
wxRealPoint *point = (wxRealPoint *)node->Data(); wxRealPoint *point = (wxRealPoint *)node->Data();
wxRealPoint *new_point = new wxRealPoint(point->x, point->y); wxRealPoint *new_point = new wxRealPoint(point->x, point->y);
copy.m_points->Append((wxObject*) new_point); polyCopy.m_points->Append((wxObject*) new_point);
node = node->Next(); node = node->Next();
} }
node = m_originalPoints->First(); node = m_originalPoints->First();
@@ -853,20 +857,13 @@ void wxPolygonShape::Copy(wxPolygonShape& copy)
{ {
wxRealPoint *point = (wxRealPoint *)node->Data(); wxRealPoint *point = (wxRealPoint *)node->Data();
wxRealPoint *new_point = new wxRealPoint(point->x, point->y); wxRealPoint *new_point = new wxRealPoint(point->x, point->y);
copy.m_originalPoints->Append((wxObject*) new_point); polyCopy.m_originalPoints->Append((wxObject*) new_point);
node = node->Next(); node = node->Next();
} }
copy.m_boundWidth = m_boundWidth; polyCopy.m_boundWidth = m_boundWidth;
copy.m_boundHeight = m_boundHeight; polyCopy.m_boundHeight = m_boundHeight;
copy.m_originalWidth = m_originalWidth; polyCopy.m_originalWidth = m_originalWidth;
copy.m_originalHeight = m_originalHeight; polyCopy.m_originalHeight = m_originalHeight;
}
wxShape *wxPolygonShape::PrivateCopy()
{
wxPolygonShape *obj = new wxPolygonShape;
Copy(*obj);
return obj;
} }
int wxPolygonShape::GetNumberOfAttachments() int wxPolygonShape::GetNumberOfAttachments()
@@ -1020,21 +1017,17 @@ void wxRectangleShape::ReadPrologAttributes(wxExpr *clause)
} }
#endif #endif
void wxRectangleShape::Copy(wxRectangleShape& copy) void wxRectangleShape::Copy(wxShape& copy)
{ {
wxShape::Copy(copy); wxShape::Copy(copy);
copy.m_width = m_width;
copy.m_height = m_height;
copy.m_cornerRadius = m_cornerRadius;
}
wxShape *wxRectangleShape::PrivateCopy() wxASSERT( copy.IsKindOf(CLASSINFO(wxRectangleShape)) );
{
wxRectangleShape *obj = new wxRectangleShape(0.0, 0.0);
Copy(*obj);
return obj;
}
wxRectangleShape& rectCopy = (wxRectangleShape&) copy;
rectCopy.m_width = m_width;
rectCopy.m_height = m_height;
rectCopy.m_cornerRadius = m_cornerRadius;
}
int wxRectangleShape::GetNumberOfAttachments() int wxRectangleShape::GetNumberOfAttachments()
{ {
@@ -1171,14 +1164,7 @@ void wxTextShape::OnDraw(wxDC& dc)
{ {
} }
wxShape *wxTextShape::PrivateCopy() void wxTextShape::Copy(wxShape& copy)
{
wxTextShape *obj = new wxTextShape(0.0, 0.0);
Copy(*obj);
return obj;
}
void wxTextShape::Copy(wxTextShape& copy)
{ {
wxRectangleShape::Copy(copy); wxRectangleShape::Copy(copy);
} }
@@ -1276,19 +1262,16 @@ void wxEllipseShape::ReadPrologAttributes(wxExpr *clause)
} }
#endif #endif
void wxEllipseShape::Copy(wxEllipseShape& copy) void wxEllipseShape::Copy(wxShape& copy)
{ {
wxShape::Copy(copy); wxShape::Copy(copy);
copy.m_width = m_width; wxASSERT( copy.IsKindOf(CLASSINFO(wxEllipseShape)) );
copy.m_height = m_height;
}
wxShape *wxEllipseShape::PrivateCopy() wxEllipseShape& ellipseCopy = (wxEllipseShape&) copy;
{
wxEllipseShape *obj = new wxEllipseShape(0.0, 0.0); ellipseCopy.m_width = m_width;
Copy(*obj); ellipseCopy.m_height = m_height;
return obj;
} }
int wxEllipseShape::GetNumberOfAttachments() int wxEllipseShape::GetNumberOfAttachments()
@@ -1368,14 +1351,7 @@ wxCircleShape::wxCircleShape(float diameter):wxEllipseShape(diameter, diameter)
{ {
} }
wxShape *wxCircleShape::PrivateCopy() void wxCircleShape::Copy(wxShape& copy)
{
wxCircleShape *obj = new wxCircleShape(0.0);
Copy(*obj);
return obj;
}
void wxCircleShape::Copy(wxCircleShape& copy)
{ {
wxEllipseShape::Copy(copy); wxEllipseShape::Copy(copy);
} }
@@ -1394,6 +1370,15 @@ bool wxCircleShape::GetPerimeterPoint(float x1, float y1,
// Control points // Control points
float wxControlPoint::controlPointDragStartX = 0.0;
float wxControlPoint::controlPointDragStartY = 0.0;
float wxControlPoint::controlPointDragStartWidth = 0.0;
float wxControlPoint::controlPointDragStartHeight = 0.0;
float wxControlPoint::controlPointDragEndWidth = 0.0;
float wxControlPoint::controlPointDragEndHeight = 0.0;
float wxControlPoint::controlPointDragPosX = 0.0;
float wxControlPoint::controlPointDragPosY = 0.0;
IMPLEMENT_DYNAMIC_CLASS(wxControlPoint, wxRectangleShape) IMPLEMENT_DYNAMIC_CLASS(wxControlPoint, wxRectangleShape)
wxControlPoint::wxControlPoint(wxShapeCanvas *theCanvas, wxShape *object, float size, float the_xoffset, float the_yoffset, int the_type):wxRectangleShape(size, size) wxControlPoint::wxControlPoint(wxShapeCanvas *theCanvas, wxShape *object, float size, float the_xoffset, float the_yoffset, int the_type):wxRectangleShape(size, size)
@@ -1431,25 +1416,41 @@ void wxControlPoint::OnErase(wxDC& dc)
wxRectangleShape::OnErase(dc); wxRectangleShape::OnErase(dc);
} }
/*
* Store original top-left, bottom-right coordinates
* in case we're doing non-vertical resizing.
*/
static float controlPointDragStartX = 0.0;
static float controlPointDragStartY = 0.0;
static float controlPointDragStartWidth = 0.0;
static float controlPointDragStartHeight = 0.0;
static float controlPointDragEndWidth = 0.0;
static float controlPointDragEndHeight = 0.0;
static float controlPointDragPosX = 0.0;
static float controlPointDragPosY = 0.0;
// Implement resizing of canvas object // Implement resizing of canvas object
void wxControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attachment) void wxControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingDragLeft(this, draw, x, y, keys, attachment);
}
void wxControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingBeginDragLeft(this, x, y, keys, attachment);
}
void wxControlPoint::OnEndDragLeft(float x, float y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingEndDragLeft(this, x, y, keys, attachment);
}
int wxControlPoint::GetNumberOfAttachments()
{
return 1;
}
bool wxControlPoint::GetAttachmentPosition(int attachment, float *x, float *y,
int nth, int no_arcs, wxLineShape *line)
{
*x = m_xpos; *y = m_ypos;
return TRUE;
}
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
void wxShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys, int attachment)
{ {
float bound_x; float bound_x;
float bound_y; float bound_y;
m_shape->GetBoundingBoxMin(&bound_x, &bound_y); this->GetBoundingBoxMin(&bound_x, &bound_y);
wxClientDC dc(GetCanvas()); wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc); GetCanvas()->PrepareDC(dc);
@@ -1460,58 +1461,53 @@ void wxControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attac
dc.SetPen(dottedPen); dc.SetPen(dottedPen);
dc.SetBrush((* wxTRANSPARENT_BRUSH)); dc.SetBrush((* wxTRANSPARENT_BRUSH));
if (m_shape->GetCentreResize()) if (this->GetCentreResize())
{ {
// Maintain the same centre point. // Maintain the same centre point.
float new_width = (float)(2.0*fabs(x - m_shape->GetX())); float new_width = (float)(2.0*fabs(x - this->GetX()));
float new_height = (float)(2.0*fabs(y - m_shape->GetY())); float new_height = (float)(2.0*fabs(y - this->GetY()));
// Constrain sizing according to what control point you're dragging // Constrain sizing according to what control point you're dragging
if (m_type == CONTROL_POINT_HORIZONTAL) if (pt->m_type == CONTROL_POINT_HORIZONTAL)
new_height = bound_y; new_height = bound_y;
else if (m_type == CONTROL_POINT_VERTICAL) else if (pt->m_type == CONTROL_POINT_VERTICAL)
new_width = bound_x; new_width = bound_x;
else if (m_type == CONTROL_POINT_DIAGONAL && (keys & KEY_SHIFT)) else if (pt->m_type == CONTROL_POINT_DIAGONAL && (keys & KEY_SHIFT))
new_height = bound_y*(new_width/bound_x); new_height = bound_y*(new_width/bound_x);
// m_shape->OnBeginSize(m_shape->m_fixedWidth ? bound_x : new_width, if (this->GetFixedWidth())
// m_shape->m_fixedHeight ? bound_y : new_height);
// m_shape->SetSize(m_shape->m_fixedWidth ? bound_x : new_width,
// m_shape->m_fixedHeight ? bound_y : new_height);
if (m_shape->GetFixedWidth())
new_width = bound_x; new_width = bound_x;
if (m_shape->GetFixedHeight()) if (this->GetFixedHeight())
new_height = bound_y; new_height = bound_y;
controlPointDragEndWidth = new_width; pt->controlPointDragEndWidth = new_width;
controlPointDragEndHeight = new_height; pt->controlPointDragEndHeight = new_height;
m_shape->GetEventHandler()->OnDrawOutline(dc, m_shape->GetX(), m_shape->GetY(), this->GetEventHandler()->OnDrawOutline(dc, this->GetX(), this->GetY(),
new_width, new_height); new_width, new_height);
} }
else else
{ {
// Don't maintain the same centre point! // Don't maintain the same centre point!
float newX1 = wxMin(controlPointDragStartX, x); float newX1 = wxMin(pt->controlPointDragStartX, x);
float newY1 = wxMin(controlPointDragStartY, y); float newY1 = wxMin(pt->controlPointDragStartY, y);
float newX2 = wxMax(controlPointDragStartX, x); float newX2 = wxMax(pt->controlPointDragStartX, x);
float newY2 = wxMax(controlPointDragStartY, y); float newY2 = wxMax(pt->controlPointDragStartY, y);
if (m_type == CONTROL_POINT_HORIZONTAL) if (pt->m_type == CONTROL_POINT_HORIZONTAL)
{ {
newY1 = controlPointDragStartY; newY1 = pt->controlPointDragStartY;
newY2 = newY1 + controlPointDragStartHeight; newY2 = newY1 + pt->controlPointDragStartHeight;
} }
else if (m_type == CONTROL_POINT_VERTICAL) else if (pt->m_type == CONTROL_POINT_VERTICAL)
{ {
newX1 = controlPointDragStartX; newX1 = pt->controlPointDragStartX;
newX2 = newX1 + controlPointDragStartWidth; newX2 = newX1 + pt->controlPointDragStartWidth;
} }
else if (m_type == CONTROL_POINT_DIAGONAL && (keys & KEY_SHIFT)) else if (pt->m_type == CONTROL_POINT_DIAGONAL && (keys & KEY_SHIFT))
{ {
float newH = (float)((newX2 - newX1)*(controlPointDragStartHeight/controlPointDragStartWidth)); float newH = (float)((newX2 - newX1)*(pt->controlPointDragStartHeight/pt->controlPointDragStartWidth));
if (GetY() > controlPointDragStartY) if (GetY() > pt->controlPointDragStartY)
newY2 = (float)(newY1 + newH); newY2 = (float)(newY1 + newH);
else else
newY1 = (float)(newY2 - newH); newY1 = (float)(newY2 - newH);
@@ -1519,114 +1515,106 @@ void wxControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attac
float newWidth = (float)(newX2 - newX1); float newWidth = (float)(newX2 - newX1);
float newHeight = (float)(newY2 - newY1); float newHeight = (float)(newY2 - newY1);
// m_shape->OnBeginSize(newWidth, pt->controlPointDragPosX = (float)(newX1 + (newWidth/2.0));
// newHeight); pt->controlPointDragPosY = (float)(newY1 + (newHeight/2.0));
if (this->GetFixedWidth())
// m_shape->SetSize(newWidth,
// newHeight);
controlPointDragPosX = (float)(newX1 + (newWidth/2.0));
controlPointDragPosY = (float)(newY1 + (newHeight/2.0));
if (m_shape->GetFixedWidth())
newWidth = bound_x; newWidth = bound_x;
if (m_shape->GetFixedHeight()) if (this->GetFixedHeight())
newHeight = bound_y; newHeight = bound_y;
controlPointDragEndWidth = newWidth; pt->controlPointDragEndWidth = newWidth;
controlPointDragEndHeight = newHeight; pt->controlPointDragEndHeight = newHeight;
m_shape->GetEventHandler()->OnDrawOutline(dc, controlPointDragPosX, controlPointDragPosY, newWidth, newHeight); this->GetEventHandler()->OnDrawOutline(dc, pt->controlPointDragPosX, pt->controlPointDragPosY, newWidth, newHeight);
} }
} }
void wxControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachment) void wxShape::OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
{ {
m_canvas->CaptureMouse(); m_canvas->CaptureMouse();
wxClientDC dc(GetCanvas()); wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc); GetCanvas()->PrepareDC(dc);
if (m_eraseObject) if (pt->m_eraseObject)
m_shape->Erase(dc); this->Erase(dc);
dc.SetLogicalFunction(wxXOR); dc.SetLogicalFunction(wxXOR);
float bound_x; float bound_x;
float bound_y; float bound_y;
m_shape->GetBoundingBoxMin(&bound_x, &bound_y); this->GetBoundingBoxMin(&bound_x, &bound_y);
// Choose the 'opposite corner' of the object as the stationary // Choose the 'opposite corner' of the object as the stationary
// point in case this is non-centring resizing. // point in case this is non-centring resizing.
if (GetX() < m_shape->GetX()) if (pt->GetX() < this->GetX())
controlPointDragStartX = (float)(m_shape->GetX() + (bound_x/2.0)); pt->controlPointDragStartX = (float)(this->GetX() + (bound_x/2.0));
else else
controlPointDragStartX = (float)(m_shape->GetX() - (bound_x/2.0)); pt->controlPointDragStartX = (float)(this->GetX() - (bound_x/2.0));
if (GetY() < m_shape->GetY()) if (pt->GetY() < this->GetY())
controlPointDragStartY = (float)(m_shape->GetY() + (bound_y/2.0)); pt->controlPointDragStartY = (float)(this->GetY() + (bound_y/2.0));
else else
controlPointDragStartY = (float)(m_shape->GetY() - (bound_y/2.0)); pt->controlPointDragStartY = (float)(this->GetY() - (bound_y/2.0));
if (m_type == CONTROL_POINT_HORIZONTAL) if (pt->m_type == CONTROL_POINT_HORIZONTAL)
controlPointDragStartY = (float)(m_shape->GetY() - (bound_y/2.0)); pt->controlPointDragStartY = (float)(this->GetY() - (bound_y/2.0));
else if (m_type == CONTROL_POINT_VERTICAL) else if (pt->m_type == CONTROL_POINT_VERTICAL)
controlPointDragStartX = (float)(m_shape->GetX() - (bound_x/2.0)); pt->controlPointDragStartX = (float)(this->GetX() - (bound_x/2.0));
// We may require the old width and height. // We may require the old width and height.
controlPointDragStartWidth = bound_x; pt->controlPointDragStartWidth = bound_x;
controlPointDragStartHeight = bound_y; pt->controlPointDragStartHeight = bound_y;
wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
dc.SetPen(dottedPen); dc.SetPen(dottedPen);
dc.SetBrush((* wxTRANSPARENT_BRUSH)); dc.SetBrush((* wxTRANSPARENT_BRUSH));
if (m_shape->GetCentreResize()) if (this->GetCentreResize())
{ {
float new_width = (float)(2.0*fabs(x - m_shape->GetX())); float new_width = (float)(2.0*fabs(x - this->GetX()));
float new_height = (float)(2.0*fabs(y - m_shape->GetY())); float new_height = (float)(2.0*fabs(y - this->GetY()));
// Constrain sizing according to what control point you're dragging // Constrain sizing according to what control point you're dragging
if (m_type == CONTROL_POINT_HORIZONTAL) if (pt->m_type == CONTROL_POINT_HORIZONTAL)
new_height = bound_y; new_height = bound_y;
else if (m_type == CONTROL_POINT_VERTICAL) else if (pt->m_type == CONTROL_POINT_VERTICAL)
new_width = bound_x; new_width = bound_x;
else if (m_type == CONTROL_POINT_DIAGONAL && (keys & KEY_SHIFT)) else if (pt->m_type == CONTROL_POINT_DIAGONAL && (keys & KEY_SHIFT))
new_height = bound_y*(new_width/bound_x); new_height = bound_y*(new_width/bound_x);
// Non-recursive SetSize for speed if (this->GetFixedWidth())
// m_shape->SetSize(new_width, new_height, FALSE);
if (m_shape->GetFixedWidth())
new_width = bound_x; new_width = bound_x;
if (m_shape->GetFixedHeight()) if (this->GetFixedHeight())
new_height = bound_y; new_height = bound_y;
controlPointDragEndWidth = new_width; pt->controlPointDragEndWidth = new_width;
controlPointDragEndHeight = new_height; pt->controlPointDragEndHeight = new_height;
m_shape->GetEventHandler()->OnDrawOutline(dc, m_shape->GetX(), m_shape->GetY(), this->GetEventHandler()->OnDrawOutline(dc, this->GetX(), this->GetY(),
new_width, new_height); new_width, new_height);
} }
else else
{ {
// Don't maintain the same centre point! // Don't maintain the same centre point!
float newX1 = wxMin(controlPointDragStartX, x); float newX1 = wxMin(pt->controlPointDragStartX, x);
float newY1 = wxMin(controlPointDragStartY, y); float newY1 = wxMin(pt->controlPointDragStartY, y);
float newX2 = wxMax(controlPointDragStartX, x); float newX2 = wxMax(pt->controlPointDragStartX, x);
float newY2 = wxMax(controlPointDragStartY, y); float newY2 = wxMax(pt->controlPointDragStartY, y);
if (m_type == CONTROL_POINT_HORIZONTAL) if (pt->m_type == CONTROL_POINT_HORIZONTAL)
{ {
newY1 = controlPointDragStartY; newY1 = pt->controlPointDragStartY;
newY2 = newY1 + controlPointDragStartHeight; newY2 = newY1 + pt->controlPointDragStartHeight;
} }
else if (m_type == CONTROL_POINT_VERTICAL) else if (pt->m_type == CONTROL_POINT_VERTICAL)
{ {
newX1 = controlPointDragStartX; newX1 = pt->controlPointDragStartX;
newX2 = newX1 + controlPointDragStartWidth; newX2 = newX1 + pt->controlPointDragStartWidth;
} }
else if (m_type == CONTROL_POINT_DIAGONAL && (keys & KEY_SHIFT)) else if (pt->m_type == CONTROL_POINT_DIAGONAL && (keys & KEY_SHIFT))
{ {
float newH = (float)((newX2 - newX1)*(controlPointDragStartHeight/controlPointDragStartWidth)); float newH = (float)((newX2 - newX1)*(pt->controlPointDragStartHeight/pt->controlPointDragStartWidth));
if (GetY() > controlPointDragStartY) if (pt->GetY() > pt->controlPointDragStartY)
newY2 = (float)(newY1 + newH); newY2 = (float)(newY1 + newH);
else else
newY1 = (float)(newY2 - newH); newY1 = (float)(newY2 - newH);
@@ -1634,51 +1622,46 @@ void wxControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachment)
float newWidth = (float)(newX2 - newX1); float newWidth = (float)(newX2 - newX1);
float newHeight = (float)(newY2 - newY1); float newHeight = (float)(newY2 - newY1);
// m_shape->OnBeginSize(newWidth, pt->controlPointDragPosX = (float)(newX1 + (newWidth/2.0));
// newHeight); pt->controlPointDragPosY = (float)(newY1 + (newHeight/2.0));
if (this->GetFixedWidth())
// m_shape->SetSize(newWidth,
// newHeight);
controlPointDragPosX = (float)(newX1 + (newWidth/2.0));
controlPointDragPosY = (float)(newY1 + (newHeight/2.0));
if (m_shape->GetFixedWidth())
newWidth = bound_x; newWidth = bound_x;
if (m_shape->GetFixedHeight()) if (this->GetFixedHeight())
newHeight = bound_y; newHeight = bound_y;
controlPointDragEndWidth = newWidth; pt->controlPointDragEndWidth = newWidth;
controlPointDragEndHeight = newHeight; pt->controlPointDragEndHeight = newHeight;
m_shape->GetEventHandler()->OnDrawOutline(dc, controlPointDragPosX, controlPointDragPosY, newWidth, newHeight); this->GetEventHandler()->OnDrawOutline(dc, pt->controlPointDragPosX, pt->controlPointDragPosY, newWidth, newHeight);
} }
} }
void wxControlPoint::OnEndDragLeft(float x, float y, int keys, int attachment) void wxShape::OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
{ {
wxClientDC dc(GetCanvas()); wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc); GetCanvas()->PrepareDC(dc);
m_canvas->ReleaseMouse(); m_canvas->ReleaseMouse();
dc.SetLogicalFunction(wxCOPY); dc.SetLogicalFunction(wxCOPY);
m_shape->Recompute(); this->Recompute();
m_shape->ResetControlPoints(); this->ResetControlPoints();
if (!m_eraseObject) if (!pt->m_eraseObject)
m_shape->Show(FALSE); this->Show(FALSE);
m_shape->SetSize(controlPointDragEndWidth, controlPointDragEndHeight); this->SetSize(pt->controlPointDragEndWidth, pt->controlPointDragEndHeight);
// The next operation could destroy this control point (it does for label objects, // The next operation could destroy this control point (it does for label objects,
// via formatting the text), so save all values we're going to use, or // via formatting the text), so save all values we're going to use, or
// we'll be accessing garbage. // we'll be accessing garbage.
wxShape *theObject = m_shape; wxShape *theObject = this;
wxShapeCanvas *theCanvas = m_canvas; wxShapeCanvas *theCanvas = m_canvas;
bool eraseIt = m_eraseObject; bool eraseIt = pt->m_eraseObject;
if (theObject->GetCentreResize()) if (theObject->GetCentreResize())
theObject->Move(dc, theObject->GetX(), theObject->GetY()); theObject->Move(dc, theObject->GetX(), theObject->GetY());
else else
theObject->Move(dc, controlPointDragPosX, controlPointDragPosY); theObject->Move(dc, pt->controlPointDragPosX, pt->controlPointDragPosY);
if (!eraseIt) if (!eraseIt)
theObject->Show(TRUE); theObject->Show(TRUE);
@@ -1694,17 +1677,6 @@ void wxControlPoint::OnEndDragLeft(float x, float y, int keys, int attachment)
if (!theCanvas->GetQuickEditMode() && eraseIt) theCanvas->Redraw(dc); if (!theCanvas->GetQuickEditMode() && eraseIt) theCanvas->Redraw(dc);
} }
int wxControlPoint::GetNumberOfAttachments()
{
return 1;
}
bool wxControlPoint::GetAttachmentPosition(int attachment, float *x, float *y,
int nth, int no_arcs, wxLineShape *line)
{
*x = m_xpos; *y = m_ypos;
return TRUE;
}
// Polygon control points // Polygon control points
@@ -1716,6 +1688,7 @@ wxPolygonControlPoint::wxPolygonControlPoint(wxShapeCanvas *theCanvas, wxShape *
wxControlPoint(theCanvas, object, size, the_xoffset, the_yoffset, 0) wxControlPoint(theCanvas, object, size, the_xoffset, the_yoffset, 0)
{ {
m_polygonVertex = vertex; m_polygonVertex = vertex;
m_originalDistance = 0.0;
} }
wxPolygonControlPoint::~wxPolygonControlPoint() wxPolygonControlPoint::~wxPolygonControlPoint()
@@ -1725,71 +1698,92 @@ wxPolygonControlPoint::~wxPolygonControlPoint()
// Implement resizing polygon or moving the vertex. // Implement resizing polygon or moving the vertex.
void wxPolygonControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attachment) void wxPolygonControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
{ {
wxClientDC dc(GetCanvas()); m_shape->GetEventHandler()->OnSizingDragLeft(this, draw, x, y, keys, attachment);
GetCanvas()->PrepareDC(dc);
dc.SetLogicalFunction(wxXOR);
wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
dc.SetPen(dottedPen);
dc.SetBrush((* wxTRANSPARENT_BRUSH));
float bound_x;
float bound_y;
m_shape->GetBoundingBoxMin(&bound_x, &bound_y);
/*
float new_width = (float)(2.0*fabs(x - m_shape->GetX()));
float new_height = (float)(2.0*fabs(y - m_shape->GetY()));
*/
float dist = (float)sqrt((x - m_shape->GetX())*(x - m_shape->GetX()) +
(y - m_shape->GetY())*(y - m_shape->GetY()));
if (keys & KEY_CTRL)
{
m_canvas->Snap(&x, &y);
// Move point
m_polygonVertex->x = x - m_shape->GetX();
m_polygonVertex->y = y - m_shape->GetY();
m_xpos = x;
m_xpos = y;
((wxPolygonShape *)m_shape)->CalculateBoundingBox();
((wxPolygonShape *)m_shape)->CalculatePolygonCentre();
}
else
{
float new_width = (float)(dist/m_originalDistance)*m_originalSize.x;
float new_height = (float)(dist/m_originalDistance)*m_originalSize.y;
// Non-recursive SetSize for speed
m_shape->SetSize(new_width, new_height, FALSE);
}
float w, h;
m_shape->GetBoundingBoxMax(&w, &h);
m_shape->GetEventHandler()->OnDrawOutline(dc, m_shape->GetX(), m_shape->GetY(), w, h);
} }
void wxPolygonControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachment) void wxPolygonControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachment)
{ {
m_shape->GetEventHandler()->OnSizingBeginDragLeft(this, x, y, keys, attachment);
}
void wxPolygonControlPoint::OnEndDragLeft(float x, float y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingEndDragLeft(this, x, y, keys, attachment);
}
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
void wxPolygonShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys, int attachment)
{
wxPolygonControlPoint* ppt = (wxPolygonControlPoint*) pt;
wxClientDC dc(GetCanvas()); wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc); GetCanvas()->PrepareDC(dc);
m_shape->Erase(dc); dc.SetLogicalFunction(wxXOR);
wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
dc.SetPen(dottedPen);
dc.SetBrush((* wxTRANSPARENT_BRUSH));
float bound_x;
float bound_y;
this->GetBoundingBoxMin(&bound_x, &bound_y);
/*
float new_width = (float)(2.0*fabs(x - this->GetX()));
float new_height = (float)(2.0*fabs(y - this->GetY()));
*/
float dist = (float)sqrt((x - this->GetX())*(x - this->GetX()) +
(y - this->GetY())*(y - this->GetY()));
if (keys & KEY_CTRL)
{
m_canvas->Snap(&x, &y);
// Move point
ppt->m_polygonVertex->x = x - this->GetX();
ppt->m_polygonVertex->y = y - this->GetY();
ppt->SetX(x);
ppt->SetY(y);
((wxPolygonShape *)this)->CalculateBoundingBox();
((wxPolygonShape *)this)->CalculatePolygonCentre();
}
else
{
float new_width = (float)(dist/ppt->m_originalDistance)*ppt->m_originalSize.x;
float new_height = (float)(dist/ppt->m_originalDistance)*ppt->m_originalSize.y;
// Non-recursive SetSize for speed
this->SetSize(new_width, new_height, FALSE);
}
float w, h;
this->GetBoundingBoxMax(&w, &h);
this->GetEventHandler()->OnDrawOutline(dc, this->GetX(), this->GetY(), w, h);
}
void wxPolygonShape::OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
{
wxPolygonControlPoint* ppt = (wxPolygonControlPoint*) pt;
wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc);
this->Erase(dc);
dc.SetLogicalFunction(wxXOR); dc.SetLogicalFunction(wxXOR);
float bound_x; float bound_x;
float bound_y; float bound_y;
m_shape->GetBoundingBoxMin(&bound_x, &bound_y); this->GetBoundingBoxMin(&bound_x, &bound_y);
float dist = (float)sqrt((x - m_shape->GetX())*(x - m_shape->GetX()) + float dist = (float)sqrt((x - this->GetX())*(x - this->GetX()) +
(y - m_shape->GetY())*(y - m_shape->GetY())); (y - this->GetY())*(y - this->GetY()));
m_originalDistance = dist; ppt->m_originalDistance = dist;
m_originalSize.x = bound_x; ppt->m_originalSize.x = bound_x;
m_originalSize.y = bound_y; ppt->m_originalSize.y = bound_y;
if (m_originalDistance == 0.0) m_originalDistance = (float) 0.0001; if (ppt->m_originalDistance == 0.0) ppt->m_originalDistance = (float) 0.0001;
wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
dc.SetPen(dottedPen); dc.SetPen(dottedPen);
@@ -1800,30 +1794,30 @@ void wxPolygonControlPoint::OnBeginDragLeft(float x, float y, int keys, int atta
m_canvas->Snap(&x, &y); m_canvas->Snap(&x, &y);
// Move point // Move point
m_polygonVertex->x = x - m_shape->GetX(); ppt->m_polygonVertex->x = x - this->GetX();
m_polygonVertex->y = y - m_shape->GetY(); ppt->m_polygonVertex->y = y - this->GetY();
m_xpos = x; ppt->SetX(x);
m_xpos = y; ppt->SetY(y);
((wxPolygonShape *)m_shape)->CalculateBoundingBox(); ((wxPolygonShape *)this)->CalculateBoundingBox();
((wxPolygonShape *)m_shape)->CalculatePolygonCentre(); ((wxPolygonShape *)this)->CalculatePolygonCentre();
} }
else else
{ {
float new_width = (float)(dist/m_originalDistance)*m_originalSize.x; float new_width = (float)(dist/ppt->m_originalDistance)*ppt->m_originalSize.x;
float new_height = (float)(dist/m_originalDistance)*m_originalSize.y; float new_height = (float)(dist/ppt->m_originalDistance)*ppt->m_originalSize.y;
// Non-recursive SetSize for speed // Non-recursive SetSize for speed
m_shape->SetSize(new_width, new_height, FALSE); this->SetSize(new_width, new_height, FALSE);
} }
float w, h; float w, h;
m_shape->GetBoundingBoxMax(&w, &h); this->GetBoundingBoxMax(&w, &h);
m_shape->GetEventHandler()->OnDrawOutline(dc, m_shape->GetX(), m_shape->GetY(), w, h); this->GetEventHandler()->OnDrawOutline(dc, this->GetX(), this->GetY(), w, h);
m_canvas->CaptureMouse(); m_canvas->CaptureMouse();
} }
void wxPolygonControlPoint::OnEndDragLeft(float x, float y, int keys, int attachment) void wxPolygonShape::OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
{ {
wxClientDC dc(GetCanvas()); wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc); GetCanvas()->PrepareDC(dc);
@@ -1834,20 +1828,19 @@ void wxPolygonControlPoint::OnEndDragLeft(float x, float y, int keys, int attach
// If we're changing shape, must reset the original points // If we're changing shape, must reset the original points
if (keys & KEY_CTRL) if (keys & KEY_CTRL)
{ {
((wxPolygonShape *)m_shape)->CalculateBoundingBox(); ((wxPolygonShape *)this)->CalculateBoundingBox();
((wxPolygonShape *)m_shape)->UpdateOriginalPoints(); ((wxPolygonShape *)this)->UpdateOriginalPoints();
} }
((wxPolygonShape *)m_shape)->CalculateBoundingBox(); ((wxPolygonShape *)this)->CalculateBoundingBox();
((wxPolygonShape *)m_shape)->CalculatePolygonCentre(); ((wxPolygonShape *)this)->CalculatePolygonCentre();
m_shape->Recompute(); this->Recompute();
m_shape->ResetControlPoints(); this->ResetControlPoints();
m_shape->Move(dc, m_shape->GetX(), m_shape->GetY()); this->Move(dc, this->GetX(), this->GetY());
if (!m_canvas->GetQuickEditMode()) m_canvas->Redraw(dc); if (!m_canvas->GetQuickEditMode()) m_canvas->Redraw(dc);
} }
/* /*
* Object region * Object region
* *

View File

@@ -40,10 +40,14 @@ protected:
float m_y; float m_y;
}; };
class wxShape;
class wxControlPoint: public wxRectangleShape class wxControlPoint: public wxRectangleShape
{ {
DECLARE_DYNAMIC_CLASS(wxControlPoint) DECLARE_DYNAMIC_CLASS(wxControlPoint)
friend class wxShapeEvtHandler;
friend class wxShape;
public: public:
wxControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, float size = 0.0, float the_xoffset = 0.0, wxControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, float size = 0.0, float the_xoffset = 0.0,
float the_yoffset = 0.0, int the_type = 0); float the_yoffset = 0.0, int the_type = 0);
@@ -70,12 +74,25 @@ public:
wxCursor* m_oldCursor; wxCursor* m_oldCursor;
bool m_eraseObject; // If TRUE, erases object before dragging handle. bool m_eraseObject; // If TRUE, erases object before dragging handle.
/*
* Store original top-left, bottom-right coordinates
* in case we're doing non-vertical resizing.
*/
static float controlPointDragStartX;
static float controlPointDragStartY;
static float controlPointDragStartWidth;
static float controlPointDragStartHeight;
static float controlPointDragEndWidth;
static float controlPointDragEndHeight;
static float controlPointDragPosX;
static float controlPointDragPosY;
}; };
class wxPolygonShape;
class wxPolygonControlPoint: public wxControlPoint class wxPolygonControlPoint: public wxControlPoint
{ {
DECLARE_DYNAMIC_CLASS(wxPolygonControlPoint) DECLARE_DYNAMIC_CLASS(wxPolygonControlPoint)
friend class wxPolygonShape;
public: public:
wxPolygonControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, float size = 0.0, wxRealPoint *vertex = NULL, wxPolygonControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, float size = 0.0, wxRealPoint *vertex = NULL,
float the_xoffset = 0.0, float the_yoffset = 0.0); float the_xoffset = 0.0, float the_yoffset = 0.0);

View File

@@ -101,19 +101,16 @@ void wxBitmapShape::ReadPrologAttributes(wxExpr *clause)
#endif #endif
// Does the copying for this object // Does the copying for this object
void wxBitmapShape::Copy(wxBitmapShape& copy) void wxBitmapShape::Copy(wxShape& copy)
{ {
wxRectangleShape::Copy(copy); wxRectangleShape::Copy(copy);
copy.m_bitmap = m_bitmap;
copy.SetFilename(m_filename);
}
// Returns a new instance, and does the copy for this class. Define for each class. wxASSERT( copy.IsKindOf(CLASSINFO(wxBitmapShape)) ) ;
wxShape *wxBitmapShape::PrivateCopy()
{ wxBitmapShape& bitmapCopy = (wxBitmapShape&) copy;
wxBitmapShape *obj = new wxBitmapShape;
Copy(*obj); bitmapCopy.m_bitmap = m_bitmap;
return obj; bitmapCopy.SetFilename(m_filename);
} }
void wxBitmapShape::SetBitmap(const wxBitmap& bm) void wxBitmapShape::SetBitmap(const wxBitmap& bm)

View File

@@ -35,10 +35,7 @@ class wxBitmapShape: public wxRectangleShape
#endif #endif
// Does the copying for this object // Does the copying for this object
void Copy(wxBitmapShape& copy); void Copy(wxShape& copy);
// Returns a new instance, and does the copy for this class. Define for each class.
wxShape *PrivateCopy();
void SetSize(float w, float h, bool recursive = TRUE); void SetSize(float w, float h, bool recursive = TRUE);
inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; } inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; }

View File

@@ -360,28 +360,32 @@ void wxCompositeShape::RemoveChildFromConstraints(wxShape *child)
} }
} }
void wxCompositeShape::Copy(wxCompositeShape& copy) void wxCompositeShape::Copy(wxShape& copy)
{ {
wxRectangleShape::Copy(copy); wxRectangleShape::Copy(copy);
// Associate old and new copies for copying constraints and division geometry wxASSERT( copy.IsKindOf(CLASSINFO(wxCompositeShape)) ) ;
wxObjectCopyMapping.Append((long)this, &copy);
wxCompositeShape& compositeCopy = (wxCompositeShape&) copy;
// Associate old and new copies for compositeCopying constraints and division geometry
wxObjectCopyMapping.Append((long)this, &compositeCopy);
// Copy the children // Copy the children
wxNode *node = m_children.First(); wxNode *node = m_children.First();
while (node) while (node)
{ {
wxShape *object = (wxShape *)node->Data(); wxShape *object = (wxShape *)node->Data();
wxShape *newObject = object->PrivateCopy(); wxShape *newObject = object->CreateNewCopy(FALSE, FALSE);
if (newObject->GetId() == 0) if (newObject->GetId() == 0)
newObject->SetId(NewId()); newObject->SetId(NewId());
newObject->SetParent(&copy); newObject->SetParent(&compositeCopy);
copy.m_children.Append(newObject); compositeCopy.m_children.Append(newObject);
// Some m_children may be divisions // Some m_children may be divisions
if (m_divisions.Member(object)) if (m_divisions.Member(object))
copy.m_divisions.Append(newObject); compositeCopy.m_divisions.Append(newObject);
wxObjectCopyMapping.Append((long)object, newObject); wxObjectCopyMapping.Append((long)object, newObject);
@@ -414,12 +418,12 @@ void wxCompositeShape::Copy(wxCompositeShape& copy)
newConstraint->m_constraintName = constraint->m_constraintName; newConstraint->m_constraintName = constraint->m_constraintName;
} }
newConstraint->SetSpacing(constraint->m_xSpacing, constraint->m_ySpacing); newConstraint->SetSpacing(constraint->m_xSpacing, constraint->m_ySpacing);
copy.m_constraints.Append(newConstraint); compositeCopy.m_constraints.Append(newConstraint);
node = node->Next(); node = node->Next();
} }
// Now copy the division geometry // Now compositeCopy the division geometry
node = m_divisions.First(); node = m_divisions.First();
while (node) while (node)
{ {
@@ -453,13 +457,6 @@ void wxCompositeShape::Copy(wxCompositeShape& copy)
} }
} }
wxShape *wxCompositeShape::PrivateCopy()
{
wxCompositeShape *obj = new wxCompositeShape;
Copy(*obj);
return obj;
}
OGLConstraint *wxCompositeShape::AddConstraint(OGLConstraint *constraint) OGLConstraint *wxCompositeShape::AddConstraint(OGLConstraint *constraint)
{ {
m_constraints.Append(constraint); m_constraints.Append(constraint);
@@ -971,29 +968,26 @@ void wxDivisionShape::CalculateSize()
{ {
} }
void wxDivisionShape::Copy(wxDivisionShape& copy) void wxDivisionShape::Copy(wxShape& copy)
{ {
wxCompositeShape::Copy(copy); wxCompositeShape::Copy(copy);
copy.m_leftSideStyle = m_leftSideStyle; wxASSERT( copy.IsKindOf(CLASSINFO(wxDivisionShape)) ) ;
copy.m_topSideStyle = m_topSideStyle;
copy.m_leftSideColour = m_leftSideColour;
copy.m_topSideColour = m_topSideColour;
copy.m_leftSidePen = m_leftSidePen; wxDivisionShape& divisionCopy = (wxDivisionShape&) copy;
copy.m_topSidePen = m_topSidePen;
copy.m_handleSide = m_handleSide; divisionCopy.m_leftSideStyle = m_leftSideStyle;
divisionCopy.m_topSideStyle = m_topSideStyle;
divisionCopy.m_leftSideColour = m_leftSideColour;
divisionCopy.m_topSideColour = m_topSideColour;
divisionCopy.m_leftSidePen = m_leftSidePen;
divisionCopy.m_topSidePen = m_topSidePen;
divisionCopy.m_handleSide = m_handleSide;
// Division geometry copying is handled at the wxCompositeShape level. // Division geometry copying is handled at the wxCompositeShape level.
} }
wxShape *wxDivisionShape::PrivateCopy()
{
wxDivisionShape *obj = new wxDivisionShape;
Copy(*obj);
return obj;
}
#ifdef PROLOGIO #ifdef PROLOGIO
void wxDivisionShape::WritePrologAttributes(wxExpr *clause) void wxDivisionShape::WritePrologAttributes(wxExpr *clause)
{ {

View File

@@ -85,8 +85,7 @@ public:
void ReadConstraints(wxExpr *clause, wxExprDatabase *database); void ReadConstraints(wxExpr *clause, wxExprDatabase *database);
#endif #endif
// Does the copying for this object // Does the copying for this object
void Copy(wxCompositeShape& copy); void Copy(wxShape& copy);
wxShape *PrivateCopy();
virtual wxDivisionShape *OnCreateDivision(); virtual wxDivisionShape *OnCreateDivision();
@@ -160,8 +159,7 @@ class wxDivisionShape: public wxCompositeShape
void ReadPrologAttributes(wxExpr *clause); void ReadPrologAttributes(wxExpr *clause);
#endif #endif
// Does the copying for this object // Does the copying for this object
void Copy(wxDivisionShape& copy); void Copy(wxShape& copy);
wxShape *PrivateCopy();
// Divide horizontally (wxHORIZONTAL) or vertically (wxVERTICAL) // Divide horizontally (wxHORIZONTAL) or vertically (wxVERTICAL)
bool Divide(int direction); bool Divide(int direction);

View File

@@ -336,18 +336,11 @@ bool wxDividedShape::AttachmentIsValid(int attachment)
return FALSE; return FALSE;
} }
void wxDividedShape::Copy(wxDividedShape& copy) void wxDividedShape::Copy(wxShape& copy)
{ {
wxRectangleShape::Copy(copy); wxRectangleShape::Copy(copy);
} }
wxShape *wxDividedShape::PrivateCopy()
{
wxDividedShape *obj = new wxDividedShape(m_width, m_height);
Copy(*obj);
return obj;
}
// Region operations // Region operations
void wxDividedShape::MakeControlPoints() void wxDividedShape::MakeControlPoints()

View File

@@ -52,8 +52,7 @@ class wxDividedShape: public wxRectangleShape
void ReadPrologAttributes(wxExpr *clause); void ReadPrologAttributes(wxExpr *clause);
#endif #endif
void Copy(wxDividedShape &copy); void Copy(wxShape &copy);
wxShape *PrivateCopy();
// Set all region sizes according to proportions and // Set all region sizes according to proportions and
// this object total size // this object total size

View File

@@ -162,19 +162,16 @@ void wxDrawnShape::ReadPrologAttributes(wxExpr *clause)
#endif #endif
// Does the copying for this object // Does the copying for this object
void wxDrawnShape::Copy(wxDrawnShape& copy) void wxDrawnShape::Copy(wxShape& copy)
{ {
wxRectangleShape::Copy(copy); wxRectangleShape::Copy(copy);
m_metafile.Copy(copy.m_metafile);
copy.m_saveToFile = m_saveToFile;
}
// Returns a new instance, and does the copy for this class. Define for each class. wxASSERT( copy.IsKindOf(CLASSINFO(wxDrawnShape)) ) ;
wxShape *wxDrawnShape::PrivateCopy()
{ wxDrawnShape& drawnCopy = (wxDrawnShape&) copy;
wxDrawnShape *obj = new wxDrawnShape;
Copy(*obj); m_metafile.Copy(drawnCopy.m_metafile);
return obj; drawnCopy.m_saveToFile = m_saveToFile;
} }
bool wxDrawnShape::LoadFromMetaFile(char *filename) bool wxDrawnShape::LoadFromMetaFile(char *filename)

View File

@@ -86,10 +86,7 @@ class wxDrawnShape: public wxRectangleShape
#endif #endif
// Does the copying for this object // Does the copying for this object
void Copy(wxDrawnShape& copy); void Copy(wxShape& copy);
// Returns a new instance, and does the copy for this class. Define for each class.
wxShape *PrivateCopy();
void Scale(float sx, float sy); void Scale(float sx, float sy);
void Translate(float x, float y); void Translate(float x, float y);

View File

@@ -1589,66 +1589,63 @@ void wxLineShape::ReadPrologAttributes(wxExpr *clause)
} }
#endif #endif
void wxLineShape::Copy(wxLineShape& copy) void wxLineShape::Copy(wxShape& copy)
{ {
wxShape::Copy(copy); wxShape::Copy(copy);
copy.m_isSpline = m_isSpline; wxASSERT( copy.IsKindOf(CLASSINFO(wxLineShape)) );
copy.m_alignmentStart = m_alignmentStart;
copy.m_alignmentEnd = m_alignmentEnd; wxLineShape& lineCopy = (wxLineShape&) copy;
copy.m_maintainStraightLines = m_maintainStraightLines;
copy.m_lineOrientations.Clear(); lineCopy.m_isSpline = m_isSpline;
lineCopy.m_alignmentStart = m_alignmentStart;
lineCopy.m_alignmentEnd = m_alignmentEnd;
lineCopy.m_maintainStraightLines = m_maintainStraightLines;
lineCopy.m_lineOrientations.Clear();
wxNode *node = m_lineOrientations.First(); wxNode *node = m_lineOrientations.First();
while (node) while (node)
{ {
copy.m_lineOrientations.Append(node->Data()); lineCopy.m_lineOrientations.Append(node->Data());
node = node->Next(); node = node->Next();
} }
if (copy.m_lineControlPoints) if (lineCopy.m_lineControlPoints)
{ {
ClearPointList(*copy.m_lineControlPoints); ClearPointList(*lineCopy.m_lineControlPoints);
delete copy.m_lineControlPoints; delete lineCopy.m_lineControlPoints;
} }
copy.m_lineControlPoints = new wxList; lineCopy.m_lineControlPoints = new wxList;
node = m_lineControlPoints->First(); node = m_lineControlPoints->First();
while (node) while (node)
{ {
wxRealPoint *point = (wxRealPoint *)node->Data(); wxRealPoint *point = (wxRealPoint *)node->Data();
wxRealPoint *new_point = new wxRealPoint(point->x, point->y); wxRealPoint *new_point = new wxRealPoint(point->x, point->y);
copy.m_lineControlPoints->Append((wxObject*) new_point); lineCopy.m_lineControlPoints->Append((wxObject*) new_point);
node = node->Next(); node = node->Next();
} }
/* /*
copy.start_style = start_style; lineCopy.start_style = start_style;
copy.end_style = end_style; lineCopy.end_style = end_style;
copy.middle_style = middle_style; lineCopy.middle_style = middle_style;
copy.arrow_length = arrow_length; lineCopy.arrow_length = arrow_length;
copy.arrow_width = arrow_width; lineCopy.arrow_width = arrow_width;
*/ */
// Copy new OGL stuff // Copy new OGL stuff
copy.ClearArrowsAtPosition(-1); lineCopy.ClearArrowsAtPosition(-1);
node = m_arcArrows.First(); node = m_arcArrows.First();
while (node) while (node)
{ {
wxArrowHead *arrow = (wxArrowHead *)node->Data(); wxArrowHead *arrow = (wxArrowHead *)node->Data();
copy.m_arcArrows.Append(new wxArrowHead(*arrow)); lineCopy.m_arcArrows.Append(new wxArrowHead(*arrow));
node = node->Next(); node = node->Next();
} }
} }
wxShape *wxLineShape::PrivateCopy()
{
wxLineShape *line = new wxLineShape;
Copy(*line);
return line;
}
// Override select, to create/delete temporary label-moving objects // Override select, to create/delete temporary label-moving objects
void wxLineShape::Select(bool select, wxDC* dc) void wxLineShape::Select(bool select, wxDC* dc)
{ {
@@ -1725,6 +1722,25 @@ void wxLineControlPoint::OnDraw(wxDC& dc)
// Implement movement of Line point // Implement movement of Line point
void wxLineControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attachment) void wxLineControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
{ {
m_shape->GetEventHandler()->OnSizingDragLeft(this, draw, x, y, keys, attachment);
}
void wxLineControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingBeginDragLeft(this, x, y, keys, attachment);
}
void wxLineControlPoint::OnEndDragLeft(float x, float y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingEndDragLeft(this, x, y, keys, attachment);
}
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
void wxLineShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys, int attachment)
{
wxLineControlPoint* lpt = (wxLineControlPoint*) pt;
wxClientDC dc(GetCanvas()); wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc); GetCanvas()->PrepareDC(dc);
@@ -1734,14 +1750,14 @@ void wxLineControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int a
dc.SetPen(dottedPen); dc.SetPen(dottedPen);
dc.SetBrush((* wxTRANSPARENT_BRUSH)); dc.SetBrush((* wxTRANSPARENT_BRUSH));
if (m_type == CONTROL_POINT_LINE) if (lpt->m_type == CONTROL_POINT_LINE)
{ {
m_canvas->Snap(&x, &y); m_canvas->Snap(&x, &y);
m_xpos = x; m_ypos = y; lpt->SetX(x); lpt->SetY(y);
m_point->x = x; m_point->y = y; lpt->m_point->x = x; lpt->m_point->y = y;
wxLineShape *lineShape = (wxLineShape *)m_shape; wxLineShape *lineShape = (wxLineShape *)this;
wxPen *old_pen = lineShape->GetPen(); wxPen *old_pen = lineShape->GetPen();
wxBrush *old_brush = lineShape->GetBrush(); wxBrush *old_brush = lineShape->GetBrush();
@@ -1756,24 +1772,26 @@ void wxLineControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int a
lineShape->SetBrush(old_brush); lineShape->SetBrush(old_brush);
} }
if (m_type == CONTROL_POINT_ENDPOINT_FROM || m_type == CONTROL_POINT_ENDPOINT_TO) if (lpt->m_type == CONTROL_POINT_ENDPOINT_FROM || lpt->m_type == CONTROL_POINT_ENDPOINT_TO)
{ {
m_xpos = x; m_ypos = y; lpt->SetX(x); lpt->SetY(y);
} }
} }
void wxLineControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachment) void wxLineShape::OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
{ {
wxLineControlPoint* lpt = (wxLineControlPoint*) pt;
wxClientDC dc(GetCanvas()); wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc); GetCanvas()->PrepareDC(dc);
wxLineShape *lineShape = (wxLineShape *)m_shape; wxLineShape *lineShape = (wxLineShape *)this;
if (m_type == CONTROL_POINT_LINE) if (lpt->m_type == CONTROL_POINT_LINE)
{ {
m_canvas->Snap(&x, &y); m_canvas->Snap(&x, &y);
m_shape->Erase(dc); this->Erase(dc);
// Redraw start and end objects because we've left holes // Redraw start and end objects because we've left holes
// when erasing the line // when erasing the line
@@ -1782,11 +1800,11 @@ void wxLineControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachm
lineShape->GetTo()->OnDraw(dc); lineShape->GetTo()->OnDraw(dc);
lineShape->GetTo()->OnDrawContents(dc); lineShape->GetTo()->OnDrawContents(dc);
m_shape->SetDisableLabel(TRUE); this->SetDisableLabel(TRUE);
dc.SetLogicalFunction(wxXOR); dc.SetLogicalFunction(wxXOR);
m_xpos = x; m_ypos = y; lpt->m_xpos = x; lpt->m_ypos = y;
m_point->x = x; m_point->y = y; lpt->m_point->x = x; lpt->m_point->y = y;
wxPen *old_pen = lineShape->GetPen(); wxPen *old_pen = lineShape->GetPen();
wxBrush *old_brush = lineShape->GetBrush(); wxBrush *old_brush = lineShape->GetBrush();
@@ -1801,11 +1819,11 @@ void wxLineControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachm
lineShape->SetBrush(old_brush); lineShape->SetBrush(old_brush);
} }
if (m_type == CONTROL_POINT_ENDPOINT_FROM || m_type == CONTROL_POINT_ENDPOINT_TO) if (lpt->m_type == CONTROL_POINT_ENDPOINT_FROM || lpt->m_type == CONTROL_POINT_ENDPOINT_TO)
{ {
Erase(dc); lpt->Erase(dc);
lineShape->OnDraw(dc); lineShape->OnDraw(dc);
if (m_type == CONTROL_POINT_ENDPOINT_FROM) if (lpt->m_type == CONTROL_POINT_ENDPOINT_FROM)
{ {
lineShape->GetFrom()->OnDraw(dc); lineShape->GetFrom()->OnDraw(dc);
lineShape->GetFrom()->OnDrawContents(dc); lineShape->GetFrom()->OnDrawContents(dc);
@@ -1816,35 +1834,37 @@ void wxLineControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachm
lineShape->GetTo()->OnDrawContents(dc); lineShape->GetTo()->OnDrawContents(dc);
} }
m_canvas->SetCursor(GraphicsBullseyeCursor); m_canvas->SetCursor(GraphicsBullseyeCursor);
m_oldCursor = wxSTANDARD_CURSOR; lpt->m_oldCursor = wxSTANDARD_CURSOR;
} }
} }
void wxLineControlPoint::OnEndDragLeft(float x, float y, int keys, int attachment) void wxLineShape::OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
{ {
wxLineControlPoint* lpt = (wxLineControlPoint*) pt;
wxClientDC dc(GetCanvas()); wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc); GetCanvas()->PrepareDC(dc);
m_shape->SetDisableLabel(FALSE); this->SetDisableLabel(FALSE);
wxLineShape *lineShape = (wxLineShape *)m_shape; wxLineShape *lineShape = (wxLineShape *)this;
if (m_type == CONTROL_POINT_LINE) if (lpt->m_type == CONTROL_POINT_LINE)
{ {
m_canvas->Snap(&x, &y); m_canvas->Snap(&x, &y);
dc.SetLogicalFunction(wxCOPY); dc.SetLogicalFunction(wxCOPY);
m_xpos = x; m_ypos = y; lpt->m_xpos = x; lpt->m_ypos = y;
m_point->x = x; m_point->y = y; lpt->m_point->x = x; lpt->m_point->y = y;
lineShape->GetEventHandler()->OnMoveLink(dc); lineShape->GetEventHandler()->OnMoveLink(dc);
} }
if (m_type == CONTROL_POINT_ENDPOINT_FROM) if (lpt->m_type == CONTROL_POINT_ENDPOINT_FROM)
{ {
if (m_oldCursor) if (lpt->m_oldCursor)
m_canvas->SetCursor(m_oldCursor); m_canvas->SetCursor(lpt->m_oldCursor);
m_shape->Erase(dc); this->Erase(dc);
m_xpos = x; m_ypos = y; lpt->m_xpos = x; lpt->m_ypos = y;
if (lineShape->GetFrom()) if (lineShape->GetFrom())
{ {
@@ -1852,12 +1872,12 @@ void wxLineControlPoint::OnEndDragLeft(float x, float y, int keys, int attachmen
lineShape->GetFrom()->MoveLinks(dc); lineShape->GetFrom()->MoveLinks(dc);
} }
} }
if (m_type == CONTROL_POINT_ENDPOINT_TO) if (lpt->m_type == CONTROL_POINT_ENDPOINT_TO)
{ {
if (m_oldCursor) if (lpt->m_oldCursor)
m_canvas->SetCursor(m_oldCursor); m_canvas->SetCursor(lpt->m_oldCursor);
m_xpos = x; m_ypos = y; lpt->m_xpos = x; lpt->m_ypos = y;
if (lineShape->GetTo()) if (lineShape->GetTo())
{ {
@@ -1867,7 +1887,7 @@ void wxLineControlPoint::OnEndDragLeft(float x, float y, int keys, int attachmen
} }
int i = 0; int i = 0;
for (i = 0; i < lineShape->GetLineControlPoints()->Number(); i++) for (i = 0; i < lineShape->GetLineControlPoints()->Number(); i++)
if (((wxRealPoint *)(lineShape->GetLineControlPoints()->Nth(i)->Data())) == m_point) if (((wxRealPoint *)(lineShape->GetLineControlPoints()->Nth(i)->Data())) == lpt->m_point)
break; break;
// N.B. in OnMoveControlPoint, an event handler in Hardy could have deselected // N.B. in OnMoveControlPoint, an event handler in Hardy could have deselected

View File

@@ -161,6 +161,12 @@ class wxLineShape: public wxShape
void OnBeginDragLeft(float x, float y, int keys=0, int attachment = 0); void OnBeginDragLeft(float x, float y, int keys=0, int attachment = 0);
void OnEndDragLeft(float x, float y, int keys=0, int attachment = 0); void OnEndDragLeft(float x, float y, int keys=0, int attachment = 0);
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys=0, int attachment = 0);
virtual void OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
virtual void OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
// Override select, to create/delete temporary label-moving objects // Override select, to create/delete temporary label-moving objects
void Select(bool select = TRUE, wxDC* dc = NULL); void Select(bool select = TRUE, wxDC* dc = NULL);
@@ -192,8 +198,7 @@ class wxLineShape: public wxShape
virtual bool Draggable() const { return FALSE; } virtual bool Draggable() const { return FALSE; }
// Does the copying for this object // Does the copying for this object
void Copy(wxLineShape& copy); void Copy(wxShape& copy);
wxShape *PrivateCopy();
// New OGL stuff // New OGL stuff
wxArrowHead *AddArrow(WXTYPE type, int end = ARROW_POSITION_END, wxArrowHead *AddArrow(WXTYPE type, int end = ARROW_POSITION_END,

View File

@@ -16,10 +16,11 @@
#pragma interface "linesp.h" #pragma interface "linesp.h"
#endif #endif
class wxLineShape;
class wxLineControlPoint: public wxControlPoint class wxLineControlPoint: public wxControlPoint
{ {
DECLARE_DYNAMIC_CLASS(wxLineControlPoint) DECLARE_DYNAMIC_CLASS(wxLineControlPoint)
friend class wxLineShape;
public: public:
wxLineControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, float size = 0.0, wxLineControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, float size = 0.0,