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}
\overview{Overview}{wxclassinfooverview}\\
\helpref{wxObject}{wxobject}
\helpref{Overview}{wxclassinfooverview}, \helpref{wxObject}{wxobject}
\latexignore{\rtfignore{\wxheading{Members}}}

View File

@ -73,6 +73,7 @@ void WXDLLEXPORT wxUnix2DosFilename(char *s);
// Strip the extension, in situ
void WXDLLEXPORT wxStripExtension(char *buffer);
void WXDLLEXPORT wxStripExtension(wxString& buffer);
// Get a temporary filename, opening and closing the file.
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)
{
m_childView = NULL;
}
// 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(),
docTemplate->GetDefaultExtension(), docTemplate->GetFileFilter(),
0, GetDocumentWindow());
wxSAVE|wxOVERWRITE_PROMPT, GetDocumentWindow());
if (!tmp)
return FALSE;
else
{
SetFilename(tmp);
SetTitle(wxFileNameFromPath(tmp));
wxString fileName(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
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()
{
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);
}
// 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)
{
if (m_previousHandler)
@ -220,7 +256,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxShape, wxShapeEvtHandler)
wxShape::wxShape(wxShapeCanvas *can)
{
m_eventHandler = this;
SetHandlerShape(this);
SetShape(this);
m_id = 0;
m_formatted = FALSE;
m_canvas = can;
@ -1876,7 +1912,7 @@ void wxShape::ReadRegions(wxExpr *clause)
m_regionProportionX = propXExpr->RealValue();
m_regionProportionY = propYExpr->RealValue();
formatMode = (formatExpr->IntegerValue() != 0);
formatMode = (int) formatExpr->IntegerValue();
fontSize = (int)sizeExpr->IntegerValue();
fontFamily = (int)familyExpr->IntegerValue();
fontStyle = (int)styleExpr->IntegerValue();
@ -2056,16 +2092,48 @@ void wxShape::Copy(wxShape& copy)
}
// Create and return a new, fully copied object.
wxShape *wxShape::CreateNewCopy(wxShapeCanvas *theCanvas)
wxShape *wxShape::CreateNewCopy(bool resetMapping, bool recompute)
{
wxObjectCopyMapping.Clear();
wxShape *newObject = PrivateCopy();
if (theCanvas)
newObject->AddToCanvas(theCanvas);
newObject->Recompute();
if (resetMapping)
wxObjectCopyMapping.Clear();
wxShape* newObject = (wxShape*) GetClassInfo()->CreateObject();
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;
}
// 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
void wxShape::MakeControlPoints()
{

View File

@ -114,9 +114,12 @@ class wxShapeEvtHandler: public wxObject
wxShapeEvtHandler(wxShapeEvtHandler *prev = NULL, wxShape *shape = NULL);
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 void SetPreviousHandler(wxShapeEvtHandler* handler) { m_previousHandler = handler; }
inline wxShapeEvtHandler* GetPreviousHandler() const { return m_previousHandler; }
// This is called when the _shape_ is deleted.
virtual void OnDelete();
virtual void OnDraw(wxDC& dc);
@ -142,9 +145,22 @@ class wxShapeEvtHandler: public wxObject
virtual void OnEraseControlPoints(wxDC& dc);
virtual void OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, 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 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:
wxShapeEvtHandler* m_previousHandler;
wxShape* m_handlerShape;
@ -207,6 +223,12 @@ class wxShape: public wxShapeEvtHandler
virtual void OnBeginSize(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 DeleteControlPoints(wxDC *dc = NULL);
virtual void ResetControlPoints();
@ -309,7 +331,7 @@ class wxShape: public wxShapeEvtHandler
virtual void NameRegions(const wxString& parentName = "");
// Get list of regions
inline wxList& GetRegions() { return m_regions; }
inline wxList& GetRegions() const { return (wxList&) m_regions; }
virtual void AddRegion(wxShapeRegion *region);
@ -341,10 +363,6 @@ class wxShape: public wxShapeEvtHandler
virtual void ReadRegions(wxExpr *clause);
#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
virtual bool GetAttachmentPosition(int attachment, float *x, float *y,
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
bool HasDescendant(wxShape *image);
// Creates a copy of this shape.
wxShape *CreateNewCopy(bool resetMapping = TRUE, bool recompute = TRUE);
// Does the copying for this object
void Copy(wxShape& copy);
// Returns a new instance, and does the copy for this class. Define for each class.
virtual wxShape *PrivateCopy() = 0;
virtual void Copy(wxShape& copy);
// Does the copying for this object, including copying event
// handler data if any. Calls the virtual Copy function.
void CopyWithHandler(wxShape& copy);
// Rotate about the given axis by the given amount in radians
// (does nothing for most objects)
@ -455,6 +478,12 @@ class wxPolygonShape: public wxShape
void OnDraw(wxDC& dc);
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,
// with the option of moving the control points individually
// to change the shape.
@ -485,8 +514,7 @@ class wxPolygonShape: public wxShape
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
bool AttachmentIsValid(int attachment);
// Does the copying for this object
void Copy(wxPolygonShape& copy);
wxShape *PrivateCopy();
void Copy(wxShape& copy);
inline wxList *GetPoints() { return m_points; }
@ -522,8 +550,7 @@ class wxRectangleShape: public wxShape
bool GetAttachmentPosition(int attachment, float *x, float *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
// Does the copying for this object
void Copy(wxRectangleShape& copy);
wxShape *PrivateCopy();
void Copy(wxShape& copy);
inline float GetWidth() const { return m_width; }
inline float GetHeight() const { return m_height; }
@ -547,8 +574,7 @@ class wxTextShape: public wxRectangleShape
#endif
// Does the copying for this object
void Copy(wxTextShape& copy);
wxShape *PrivateCopy();
void Copy(wxShape& copy);
};
class wxEllipseShape: public wxShape
@ -576,8 +602,7 @@ class wxEllipseShape: public wxShape
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
// Does the copying for this object
void Copy(wxEllipseShape& copy);
wxShape *PrivateCopy();
void Copy(wxShape& copy);
inline float GetWidth() const { return m_width; }
inline float GetHeight() const { return m_height; }
@ -597,8 +622,7 @@ class wxCircleShape: public wxEllipseShape
float x2, float y2,
float *x3, float *y3);
// Does the copying for this object
void Copy(wxCircleShape& copy);
wxShape *PrivateCopy();
void Copy(wxShape& copy);
};
#endif

View File

@ -826,26 +826,30 @@ void wxPolygonShape::ReadPrologAttributes(wxExpr *clause)
}
#endif
void wxPolygonShape::Copy(wxPolygonShape& copy)
void wxPolygonShape::Copy(wxShape& copy)
{
wxShape::Copy(copy);
if (copy.m_points)
delete copy.m_points;
wxASSERT( copy.IsKindOf(CLASSINFO(wxPolygonShape)) );
copy.m_points = new wxList;
wxPolygonShape& polyCopy = (wxPolygonShape&) copy;
if (copy.m_originalPoints)
delete copy.m_originalPoints;
if (polyCopy.m_points)
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();
while (node)
{
wxRealPoint *point = (wxRealPoint *)node->Data();
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 = m_originalPoints->First();
@ -853,20 +857,13 @@ void wxPolygonShape::Copy(wxPolygonShape& copy)
{
wxRealPoint *point = (wxRealPoint *)node->Data();
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();
}
copy.m_boundWidth = m_boundWidth;
copy.m_boundHeight = m_boundHeight;
copy.m_originalWidth = m_originalWidth;
copy.m_originalHeight = m_originalHeight;
}
wxShape *wxPolygonShape::PrivateCopy()
{
wxPolygonShape *obj = new wxPolygonShape;
Copy(*obj);
return obj;
polyCopy.m_boundWidth = m_boundWidth;
polyCopy.m_boundHeight = m_boundHeight;
polyCopy.m_originalWidth = m_originalWidth;
polyCopy.m_originalHeight = m_originalHeight;
}
int wxPolygonShape::GetNumberOfAttachments()
@ -1020,21 +1017,17 @@ void wxRectangleShape::ReadPrologAttributes(wxExpr *clause)
}
#endif
void wxRectangleShape::Copy(wxRectangleShape& copy)
void wxRectangleShape::Copy(wxShape& copy)
{
wxShape::Copy(copy);
copy.m_width = m_width;
copy.m_height = m_height;
copy.m_cornerRadius = m_cornerRadius;
}
wxShape *wxRectangleShape::PrivateCopy()
{
wxRectangleShape *obj = new wxRectangleShape(0.0, 0.0);
Copy(*obj);
return obj;
}
wxASSERT( copy.IsKindOf(CLASSINFO(wxRectangleShape)) );
wxRectangleShape& rectCopy = (wxRectangleShape&) copy;
rectCopy.m_width = m_width;
rectCopy.m_height = m_height;
rectCopy.m_cornerRadius = m_cornerRadius;
}
int wxRectangleShape::GetNumberOfAttachments()
{
@ -1171,14 +1164,7 @@ void wxTextShape::OnDraw(wxDC& dc)
{
}
wxShape *wxTextShape::PrivateCopy()
{
wxTextShape *obj = new wxTextShape(0.0, 0.0);
Copy(*obj);
return obj;
}
void wxTextShape::Copy(wxTextShape& copy)
void wxTextShape::Copy(wxShape& copy)
{
wxRectangleShape::Copy(copy);
}
@ -1276,19 +1262,16 @@ void wxEllipseShape::ReadPrologAttributes(wxExpr *clause)
}
#endif
void wxEllipseShape::Copy(wxEllipseShape& copy)
void wxEllipseShape::Copy(wxShape& copy)
{
wxShape::Copy(copy);
copy.m_width = m_width;
copy.m_height = m_height;
}
wxASSERT( copy.IsKindOf(CLASSINFO(wxEllipseShape)) );
wxShape *wxEllipseShape::PrivateCopy()
{
wxEllipseShape *obj = new wxEllipseShape(0.0, 0.0);
Copy(*obj);
return obj;
wxEllipseShape& ellipseCopy = (wxEllipseShape&) copy;
ellipseCopy.m_width = m_width;
ellipseCopy.m_height = m_height;
}
int wxEllipseShape::GetNumberOfAttachments()
@ -1368,14 +1351,7 @@ wxCircleShape::wxCircleShape(float diameter):wxEllipseShape(diameter, diameter)
{
}
wxShape *wxCircleShape::PrivateCopy()
{
wxCircleShape *obj = new wxCircleShape(0.0);
Copy(*obj);
return obj;
}
void wxCircleShape::Copy(wxCircleShape& copy)
void wxCircleShape::Copy(wxShape& copy)
{
wxEllipseShape::Copy(copy);
}
@ -1394,6 +1370,15 @@ bool wxCircleShape::GetPerimeterPoint(float x1, float y1,
// 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)
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);
}
/*
* 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
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_y;
m_shape->GetBoundingBoxMin(&bound_x, &bound_y);
this->GetBoundingBoxMin(&bound_x, &bound_y);
wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc);
@ -1460,58 +1461,53 @@ void wxControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attac
dc.SetPen(dottedPen);
dc.SetBrush((* wxTRANSPARENT_BRUSH));
if (m_shape->GetCentreResize())
if (this->GetCentreResize())
{
// Maintain the same centre point.
float new_width = (float)(2.0*fabs(x - m_shape->GetX()));
float new_height = (float)(2.0*fabs(y - m_shape->GetY()));
float new_width = (float)(2.0*fabs(x - this->GetX()));
float new_height = (float)(2.0*fabs(y - this->GetY()));
// 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;
else if (m_type == CONTROL_POINT_VERTICAL)
else if (pt->m_type == CONTROL_POINT_VERTICAL)
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);
// m_shape->OnBeginSize(m_shape->m_fixedWidth ? bound_x : new_width,
// 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())
if (this->GetFixedWidth())
new_width = bound_x;
if (m_shape->GetFixedHeight())
if (this->GetFixedHeight())
new_height = bound_y;
controlPointDragEndWidth = new_width;
controlPointDragEndHeight = new_height;
pt->controlPointDragEndWidth = new_width;
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);
}
else
{
// Don't maintain the same centre point!
float newX1 = wxMin(controlPointDragStartX, x);
float newY1 = wxMin(controlPointDragStartY, y);
float newX2 = wxMax(controlPointDragStartX, x);
float newY2 = wxMax(controlPointDragStartY, y);
if (m_type == CONTROL_POINT_HORIZONTAL)
float newX1 = wxMin(pt->controlPointDragStartX, x);
float newY1 = wxMin(pt->controlPointDragStartY, y);
float newX2 = wxMax(pt->controlPointDragStartX, x);
float newY2 = wxMax(pt->controlPointDragStartY, y);
if (pt->m_type == CONTROL_POINT_HORIZONTAL)
{
newY1 = controlPointDragStartY;
newY2 = newY1 + controlPointDragStartHeight;
newY1 = pt->controlPointDragStartY;
newY2 = newY1 + pt->controlPointDragStartHeight;
}
else if (m_type == CONTROL_POINT_VERTICAL)
else if (pt->m_type == CONTROL_POINT_VERTICAL)
{
newX1 = controlPointDragStartX;
newX2 = newX1 + controlPointDragStartWidth;
newX1 = pt->controlPointDragStartX;
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));
if (GetY() > controlPointDragStartY)
float newH = (float)((newX2 - newX1)*(pt->controlPointDragStartHeight/pt->controlPointDragStartWidth));
if (GetY() > pt->controlPointDragStartY)
newY2 = (float)(newY1 + newH);
else
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 newHeight = (float)(newY2 - newY1);
// m_shape->OnBeginSize(newWidth,
// newHeight);
// m_shape->SetSize(newWidth,
// newHeight);
controlPointDragPosX = (float)(newX1 + (newWidth/2.0));
controlPointDragPosY = (float)(newY1 + (newHeight/2.0));
if (m_shape->GetFixedWidth())
pt->controlPointDragPosX = (float)(newX1 + (newWidth/2.0));
pt->controlPointDragPosY = (float)(newY1 + (newHeight/2.0));
if (this->GetFixedWidth())
newWidth = bound_x;
if (m_shape->GetFixedHeight())
if (this->GetFixedHeight())
newHeight = bound_y;
controlPointDragEndWidth = newWidth;
controlPointDragEndHeight = newHeight;
m_shape->GetEventHandler()->OnDrawOutline(dc, controlPointDragPosX, controlPointDragPosY, newWidth, newHeight);
pt->controlPointDragEndWidth = newWidth;
pt->controlPointDragEndHeight = 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();
wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc);
if (m_eraseObject)
m_shape->Erase(dc);
if (pt->m_eraseObject)
this->Erase(dc);
dc.SetLogicalFunction(wxXOR);
float bound_x;
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
// point in case this is non-centring resizing.
if (GetX() < m_shape->GetX())
controlPointDragStartX = (float)(m_shape->GetX() + (bound_x/2.0));
if (pt->GetX() < this->GetX())
pt->controlPointDragStartX = (float)(this->GetX() + (bound_x/2.0));
else
controlPointDragStartX = (float)(m_shape->GetX() - (bound_x/2.0));
pt->controlPointDragStartX = (float)(this->GetX() - (bound_x/2.0));
if (GetY() < m_shape->GetY())
controlPointDragStartY = (float)(m_shape->GetY() + (bound_y/2.0));
if (pt->GetY() < this->GetY())
pt->controlPointDragStartY = (float)(this->GetY() + (bound_y/2.0));
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)
controlPointDragStartY = (float)(m_shape->GetY() - (bound_y/2.0));
else if (m_type == CONTROL_POINT_VERTICAL)
controlPointDragStartX = (float)(m_shape->GetX() - (bound_x/2.0));
if (pt->m_type == CONTROL_POINT_HORIZONTAL)
pt->controlPointDragStartY = (float)(this->GetY() - (bound_y/2.0));
else if (pt->m_type == CONTROL_POINT_VERTICAL)
pt->controlPointDragStartX = (float)(this->GetX() - (bound_x/2.0));
// We may require the old width and height.
controlPointDragStartWidth = bound_x;
controlPointDragStartHeight = bound_y;
pt->controlPointDragStartWidth = bound_x;
pt->controlPointDragStartHeight = bound_y;
wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
dc.SetPen(dottedPen);
dc.SetBrush((* wxTRANSPARENT_BRUSH));
if (m_shape->GetCentreResize())
if (this->GetCentreResize())
{
float new_width = (float)(2.0*fabs(x - m_shape->GetX()));
float new_height = (float)(2.0*fabs(y - m_shape->GetY()));
float new_width = (float)(2.0*fabs(x - this->GetX()));
float new_height = (float)(2.0*fabs(y - this->GetY()));
// 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;
else if (m_type == CONTROL_POINT_VERTICAL)
else if (pt->m_type == CONTROL_POINT_VERTICAL)
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);
// Non-recursive SetSize for speed
// m_shape->SetSize(new_width, new_height, FALSE);
if (m_shape->GetFixedWidth())
if (this->GetFixedWidth())
new_width = bound_x;
if (m_shape->GetFixedHeight())
if (this->GetFixedHeight())
new_height = bound_y;
controlPointDragEndWidth = new_width;
controlPointDragEndHeight = new_height;
m_shape->GetEventHandler()->OnDrawOutline(dc, m_shape->GetX(), m_shape->GetY(),
pt->controlPointDragEndWidth = new_width;
pt->controlPointDragEndHeight = new_height;
this->GetEventHandler()->OnDrawOutline(dc, this->GetX(), this->GetY(),
new_width, new_height);
}
else
{
// Don't maintain the same centre point!
float newX1 = wxMin(controlPointDragStartX, x);
float newY1 = wxMin(controlPointDragStartY, y);
float newX2 = wxMax(controlPointDragStartX, x);
float newY2 = wxMax(controlPointDragStartY, y);
if (m_type == CONTROL_POINT_HORIZONTAL)
float newX1 = wxMin(pt->controlPointDragStartX, x);
float newY1 = wxMin(pt->controlPointDragStartY, y);
float newX2 = wxMax(pt->controlPointDragStartX, x);
float newY2 = wxMax(pt->controlPointDragStartY, y);
if (pt->m_type == CONTROL_POINT_HORIZONTAL)
{
newY1 = controlPointDragStartY;
newY2 = newY1 + controlPointDragStartHeight;
newY1 = pt->controlPointDragStartY;
newY2 = newY1 + pt->controlPointDragStartHeight;
}
else if (m_type == CONTROL_POINT_VERTICAL)
else if (pt->m_type == CONTROL_POINT_VERTICAL)
{
newX1 = controlPointDragStartX;
newX2 = newX1 + controlPointDragStartWidth;
newX1 = pt->controlPointDragStartX;
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));
if (GetY() > controlPointDragStartY)
float newH = (float)((newX2 - newX1)*(pt->controlPointDragStartHeight/pt->controlPointDragStartWidth));
if (pt->GetY() > pt->controlPointDragStartY)
newY2 = (float)(newY1 + newH);
else
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 newHeight = (float)(newY2 - newY1);
// m_shape->OnBeginSize(newWidth,
// newHeight);
// m_shape->SetSize(newWidth,
// newHeight);
controlPointDragPosX = (float)(newX1 + (newWidth/2.0));
controlPointDragPosY = (float)(newY1 + (newHeight/2.0));
if (m_shape->GetFixedWidth())
pt->controlPointDragPosX = (float)(newX1 + (newWidth/2.0));
pt->controlPointDragPosY = (float)(newY1 + (newHeight/2.0));
if (this->GetFixedWidth())
newWidth = bound_x;
if (m_shape->GetFixedHeight())
if (this->GetFixedHeight())
newHeight = bound_y;
controlPointDragEndWidth = newWidth;
controlPointDragEndHeight = newHeight;
m_shape->GetEventHandler()->OnDrawOutline(dc, controlPointDragPosX, controlPointDragPosY, newWidth, newHeight);
pt->controlPointDragEndWidth = newWidth;
pt->controlPointDragEndHeight = 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());
GetCanvas()->PrepareDC(dc);
m_canvas->ReleaseMouse();
dc.SetLogicalFunction(wxCOPY);
m_shape->Recompute();
m_shape->ResetControlPoints();
this->Recompute();
this->ResetControlPoints();
if (!m_eraseObject)
m_shape->Show(FALSE);
if (!pt->m_eraseObject)
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,
// via formatting the text), so save all values we're going to use, or
// we'll be accessing garbage.
wxShape *theObject = m_shape;
wxShape *theObject = this;
wxShapeCanvas *theCanvas = m_canvas;
bool eraseIt = m_eraseObject;
bool eraseIt = pt->m_eraseObject;
if (theObject->GetCentreResize())
theObject->Move(dc, theObject->GetX(), theObject->GetY());
else
theObject->Move(dc, controlPointDragPosX, controlPointDragPosY);
theObject->Move(dc, pt->controlPointDragPosX, pt->controlPointDragPosY);
if (!eraseIt)
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);
}
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
@ -1716,6 +1688,7 @@ wxPolygonControlPoint::wxPolygonControlPoint(wxShapeCanvas *theCanvas, wxShape *
wxControlPoint(theCanvas, object, size, the_xoffset, the_yoffset, 0)
{
m_polygonVertex = vertex;
m_originalDistance = 0.0;
}
wxPolygonControlPoint::~wxPolygonControlPoint()
@ -1725,71 +1698,92 @@ wxPolygonControlPoint::~wxPolygonControlPoint()
// Implement resizing polygon or moving the vertex.
void wxPolygonControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
{
wxClientDC dc(GetCanvas());
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);
m_shape->GetEventHandler()->OnSizingDragLeft(this, draw, x, y, keys, 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());
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);
float bound_x;
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()) +
(y - m_shape->GetY())*(y - m_shape->GetY()));
float dist = (float)sqrt((x - this->GetX())*(x - this->GetX()) +
(y - this->GetY())*(y - this->GetY()));
m_originalDistance = dist;
m_originalSize.x = bound_x;
m_originalSize.y = bound_y;
ppt->m_originalDistance = dist;
ppt->m_originalSize.x = bound_x;
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);
dc.SetPen(dottedPen);
@ -1800,30 +1794,30 @@ void wxPolygonControlPoint::OnBeginDragLeft(float x, float y, int keys, int atta
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();
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/m_originalDistance)*m_originalSize.x;
float new_height = (float)(dist/m_originalDistance)*m_originalSize.y;
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
m_shape->SetSize(new_width, new_height, FALSE);
this->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);
this->GetBoundingBoxMax(&w, &h);
this->GetEventHandler()->OnDrawOutline(dc, this->GetX(), this->GetY(), w, h);
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());
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 (keys & KEY_CTRL)
{
((wxPolygonShape *)m_shape)->CalculateBoundingBox();
((wxPolygonShape *)m_shape)->UpdateOriginalPoints();
((wxPolygonShape *)this)->CalculateBoundingBox();
((wxPolygonShape *)this)->UpdateOriginalPoints();
}
((wxPolygonShape *)m_shape)->CalculateBoundingBox();
((wxPolygonShape *)m_shape)->CalculatePolygonCentre();
((wxPolygonShape *)this)->CalculateBoundingBox();
((wxPolygonShape *)this)->CalculatePolygonCentre();
m_shape->Recompute();
m_shape->ResetControlPoints();
m_shape->Move(dc, m_shape->GetX(), m_shape->GetY());
this->Recompute();
this->ResetControlPoints();
this->Move(dc, this->GetX(), this->GetY());
if (!m_canvas->GetQuickEditMode()) m_canvas->Redraw(dc);
}
/*
* Object region
*

View File

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

View File

@ -101,19 +101,16 @@ void wxBitmapShape::ReadPrologAttributes(wxExpr *clause)
#endif
// Does the copying for this object
void wxBitmapShape::Copy(wxBitmapShape& copy)
void wxBitmapShape::Copy(wxShape& 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.
wxShape *wxBitmapShape::PrivateCopy()
{
wxBitmapShape *obj = new wxBitmapShape;
Copy(*obj);
return obj;
wxASSERT( copy.IsKindOf(CLASSINFO(wxBitmapShape)) ) ;
wxBitmapShape& bitmapCopy = (wxBitmapShape&) copy;
bitmapCopy.m_bitmap = m_bitmap;
bitmapCopy.SetFilename(m_filename);
}
void wxBitmapShape::SetBitmap(const wxBitmap& bm)

View File

@ -35,10 +35,7 @@ class wxBitmapShape: public wxRectangleShape
#endif
// Does the copying for this object
void Copy(wxBitmapShape& copy);
// Returns a new instance, and does the copy for this class. Define for each class.
wxShape *PrivateCopy();
void Copy(wxShape& copy);
void SetSize(float w, float h, bool recursive = TRUE);
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);
// Associate old and new copies for copying constraints and division geometry
wxObjectCopyMapping.Append((long)this, &copy);
wxASSERT( copy.IsKindOf(CLASSINFO(wxCompositeShape)) ) ;
wxCompositeShape& compositeCopy = (wxCompositeShape&) copy;
// Associate old and new copies for compositeCopying constraints and division geometry
wxObjectCopyMapping.Append((long)this, &compositeCopy);
// Copy the children
wxNode *node = m_children.First();
while (node)
{
wxShape *object = (wxShape *)node->Data();
wxShape *newObject = object->PrivateCopy();
wxShape *newObject = object->CreateNewCopy(FALSE, FALSE);
if (newObject->GetId() == 0)
newObject->SetId(NewId());
newObject->SetParent(&copy);
copy.m_children.Append(newObject);
newObject->SetParent(&compositeCopy);
compositeCopy.m_children.Append(newObject);
// Some m_children may be divisions
if (m_divisions.Member(object))
copy.m_divisions.Append(newObject);
compositeCopy.m_divisions.Append(newObject);
wxObjectCopyMapping.Append((long)object, newObject);
@ -414,12 +418,12 @@ void wxCompositeShape::Copy(wxCompositeShape& copy)
newConstraint->m_constraintName = constraint->m_constraintName;
}
newConstraint->SetSpacing(constraint->m_xSpacing, constraint->m_ySpacing);
copy.m_constraints.Append(newConstraint);
compositeCopy.m_constraints.Append(newConstraint);
node = node->Next();
}
// Now copy the division geometry
// Now compositeCopy the division geometry
node = m_divisions.First();
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)
{
m_constraints.Append(constraint);
@ -971,29 +968,26 @@ void wxDivisionShape::CalculateSize()
{
}
void wxDivisionShape::Copy(wxDivisionShape& copy)
void wxDivisionShape::Copy(wxShape& copy)
{
wxCompositeShape::Copy(copy);
copy.m_leftSideStyle = m_leftSideStyle;
copy.m_topSideStyle = m_topSideStyle;
copy.m_leftSideColour = m_leftSideColour;
copy.m_topSideColour = m_topSideColour;
wxASSERT( copy.IsKindOf(CLASSINFO(wxDivisionShape)) ) ;
copy.m_leftSidePen = m_leftSidePen;
copy.m_topSidePen = m_topSidePen;
copy.m_handleSide = m_handleSide;
wxDivisionShape& divisionCopy = (wxDivisionShape&) copy;
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.
}
wxShape *wxDivisionShape::PrivateCopy()
{
wxDivisionShape *obj = new wxDivisionShape;
Copy(*obj);
return obj;
}
#ifdef PROLOGIO
void wxDivisionShape::WritePrologAttributes(wxExpr *clause)
{

View File

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

View File

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

View File

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

View File

@ -162,19 +162,16 @@ void wxDrawnShape::ReadPrologAttributes(wxExpr *clause)
#endif
// Does the copying for this object
void wxDrawnShape::Copy(wxDrawnShape& copy)
void wxDrawnShape::Copy(wxShape& 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.
wxShape *wxDrawnShape::PrivateCopy()
{
wxDrawnShape *obj = new wxDrawnShape;
Copy(*obj);
return obj;
wxASSERT( copy.IsKindOf(CLASSINFO(wxDrawnShape)) ) ;
wxDrawnShape& drawnCopy = (wxDrawnShape&) copy;
m_metafile.Copy(drawnCopy.m_metafile);
drawnCopy.m_saveToFile = m_saveToFile;
}
bool wxDrawnShape::LoadFromMetaFile(char *filename)

View File

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

View File

@ -1589,66 +1589,63 @@ void wxLineShape::ReadPrologAttributes(wxExpr *clause)
}
#endif
void wxLineShape::Copy(wxLineShape& copy)
void wxLineShape::Copy(wxShape& copy)
{
wxShape::Copy(copy);
copy.m_isSpline = m_isSpline;
copy.m_alignmentStart = m_alignmentStart;
copy.m_alignmentEnd = m_alignmentEnd;
copy.m_maintainStraightLines = m_maintainStraightLines;
copy.m_lineOrientations.Clear();
wxASSERT( copy.IsKindOf(CLASSINFO(wxLineShape)) );
wxLineShape& lineCopy = (wxLineShape&) copy;
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();
while (node)
{
copy.m_lineOrientations.Append(node->Data());
lineCopy.m_lineOrientations.Append(node->Data());
node = node->Next();
}
if (copy.m_lineControlPoints)
if (lineCopy.m_lineControlPoints)
{
ClearPointList(*copy.m_lineControlPoints);
delete copy.m_lineControlPoints;
ClearPointList(*lineCopy.m_lineControlPoints);
delete lineCopy.m_lineControlPoints;
}
copy.m_lineControlPoints = new wxList;
lineCopy.m_lineControlPoints = new wxList;
node = m_lineControlPoints->First();
while (node)
{
wxRealPoint *point = (wxRealPoint *)node->Data();
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();
}
/*
copy.start_style = start_style;
copy.end_style = end_style;
copy.middle_style = middle_style;
lineCopy.start_style = start_style;
lineCopy.end_style = end_style;
lineCopy.middle_style = middle_style;
copy.arrow_length = arrow_length;
copy.arrow_width = arrow_width;
lineCopy.arrow_length = arrow_length;
lineCopy.arrow_width = arrow_width;
*/
// Copy new OGL stuff
copy.ClearArrowsAtPosition(-1);
lineCopy.ClearArrowsAtPosition(-1);
node = m_arcArrows.First();
while (node)
{
wxArrowHead *arrow = (wxArrowHead *)node->Data();
copy.m_arcArrows.Append(new wxArrowHead(*arrow));
lineCopy.m_arcArrows.Append(new wxArrowHead(*arrow));
node = node->Next();
}
}
wxShape *wxLineShape::PrivateCopy()
{
wxLineShape *line = new wxLineShape;
Copy(*line);
return line;
}
// Override select, to create/delete temporary label-moving objects
void wxLineShape::Select(bool select, wxDC* dc)
{
@ -1725,6 +1722,25 @@ void wxLineControlPoint::OnDraw(wxDC& dc)
// Implement movement of Line point
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());
GetCanvas()->PrepareDC(dc);
@ -1734,14 +1750,14 @@ void wxLineControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int a
dc.SetPen(dottedPen);
dc.SetBrush((* wxTRANSPARENT_BRUSH));
if (m_type == CONTROL_POINT_LINE)
if (lpt->m_type == CONTROL_POINT_LINE)
{
m_canvas->Snap(&x, &y);
m_xpos = x; m_ypos = y;
m_point->x = x; m_point->y = y;
lpt->SetX(x); lpt->SetY(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();
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);
}
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());
GetCanvas()->PrepareDC(dc);
wxLineShape *lineShape = (wxLineShape *)m_shape;
if (m_type == CONTROL_POINT_LINE)
wxLineShape *lineShape = (wxLineShape *)this;
if (lpt->m_type == CONTROL_POINT_LINE)
{
m_canvas->Snap(&x, &y);
m_shape->Erase(dc);
this->Erase(dc);
// Redraw start and end objects because we've left holes
// 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()->OnDrawContents(dc);
m_shape->SetDisableLabel(TRUE);
this->SetDisableLabel(TRUE);
dc.SetLogicalFunction(wxXOR);
m_xpos = x; m_ypos = y;
m_point->x = x; m_point->y = y;
lpt->m_xpos = x; lpt->m_ypos = y;
lpt->m_point->x = x; lpt->m_point->y = y;
wxPen *old_pen = lineShape->GetPen();
wxBrush *old_brush = lineShape->GetBrush();
@ -1801,11 +1819,11 @@ void wxLineControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachm
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);
if (m_type == CONTROL_POINT_ENDPOINT_FROM)
if (lpt->m_type == CONTROL_POINT_ENDPOINT_FROM)
{
lineShape->GetFrom()->OnDraw(dc);
lineShape->GetFrom()->OnDrawContents(dc);
@ -1816,35 +1834,37 @@ void wxLineControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachm
lineShape->GetTo()->OnDrawContents(dc);
}
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());
GetCanvas()->PrepareDC(dc);
m_shape->SetDisableLabel(FALSE);
wxLineShape *lineShape = (wxLineShape *)m_shape;
this->SetDisableLabel(FALSE);
wxLineShape *lineShape = (wxLineShape *)this;
if (m_type == CONTROL_POINT_LINE)
if (lpt->m_type == CONTROL_POINT_LINE)
{
m_canvas->Snap(&x, &y);
dc.SetLogicalFunction(wxCOPY);
m_xpos = x; m_ypos = y;
m_point->x = x; m_point->y = y;
lpt->m_xpos = x; lpt->m_ypos = y;
lpt->m_point->x = x; lpt->m_point->y = y;
lineShape->GetEventHandler()->OnMoveLink(dc);
}
if (m_type == CONTROL_POINT_ENDPOINT_FROM)
if (lpt->m_type == CONTROL_POINT_ENDPOINT_FROM)
{
if (m_oldCursor)
m_canvas->SetCursor(m_oldCursor);
m_shape->Erase(dc);
if (lpt->m_oldCursor)
m_canvas->SetCursor(lpt->m_oldCursor);
this->Erase(dc);
m_xpos = x; m_ypos = y;
lpt->m_xpos = x; lpt->m_ypos = y;
if (lineShape->GetFrom())
{
@ -1852,12 +1872,12 @@ void wxLineControlPoint::OnEndDragLeft(float x, float y, int keys, int attachmen
lineShape->GetFrom()->MoveLinks(dc);
}
}
if (m_type == CONTROL_POINT_ENDPOINT_TO)
if (lpt->m_type == CONTROL_POINT_ENDPOINT_TO)
{
if (m_oldCursor)
m_canvas->SetCursor(m_oldCursor);
if (lpt->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())
{
@ -1867,7 +1887,7 @@ void wxLineControlPoint::OnEndDragLeft(float x, float y, int keys, int attachmen
}
int i = 0;
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;
// 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 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
void Select(bool select = TRUE, wxDC* dc = NULL);
@ -192,8 +198,7 @@ class wxLineShape: public wxShape
virtual bool Draggable() const { return FALSE; }
// Does the copying for this object
void Copy(wxLineShape& copy);
wxShape *PrivateCopy();
void Copy(wxShape& copy);
// New OGL stuff
wxArrowHead *AddArrow(WXTYPE type, int end = ARROW_POSITION_END,

View File

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