private:
wxListBox *m_ctrlFile,
- *m_ctrlText;
+ *m_ctrlText;
wxTextCtrl *m_ctrlLog;
- wxLog *m_pLog, *m_pLogPrev;
+ wxLog *m_pLog,
+ *m_pLogPrev;
wxString m_strText;
wxBitmap m_bitmap;
const wxColour& col)
: DnDShape(pos, size, col)
{
+ wxLogMessage("DnDTriangularShape is being created");
}
virtual ~DnDTriangularShape()
const wxColour& col)
: DnDShape(pos, size, col)
{
+ wxLogMessage("DnDRectangularShape is being created");
}
virtual ~DnDRectangularShape()
const wxColour& col)
: DnDShape(pos, size, col)
{
+ wxLogMessage("DnDEllipticShape is being created");
}
virtual ~DnDEllipticShape()
virtual ~DnDShapeDataObject() { delete m_shape; }
- // accessors
- DnDShape *GetShape() const { return m_shape; }
+ // after a call to this function, the shape is owned by the caller and it
+ // is responsible for deleting it!
+ //
+ // NB: a better solution would be to make DnDShapes ref counted and this
+ // is what should probably be done in a real life program, otherwise
+ // the ownership problems become too complicated really fast
+ DnDShape *GetShape()
+ {
+ DnDShape *shape = m_shape;
+
+ m_shape = (DnDShape *)NULL;
+ m_hasBitmap = FALSE;
+
+ return shape;
+ }
// implement base class pure virtuals
// ----------------------------------
void OnDrag(wxMouseEvent& event);
void OnPaint(wxPaintEvent& event);
- void OnDrop(long x, long y, DnDShape *shape);
+ void OnDrop(wxCoord x, wxCoord y, DnDShape *shape);
private:
DnDShape *m_shape;
//else: status text already set
}
-void DnDShapeFrame::OnDrop(long x, long y, DnDShape *shape)
+void DnDShapeFrame::OnDrop(wxCoord x, wxCoord y, DnDShape *shape)
{
ms_lastDropTarget = this;
+ wxPoint pt(x, y);
+#ifdef __WXMSW__ //temporary hack (FIXME)
+ pt = ScreenToClient(pt);
+#endif
+
wxString s;
- s.Printf("Shape dropped at (%ld, %ld)", x, y);
+ s.Printf("Shape dropped at (%ld, %ld)", pt.x, pt.y);
SetStatusText(s);
- shape->Move(ScreenToClient(wxPoint(x, y)));
+ shape->Move(pt);
SetShape(shape);
}