~s-cecilio/lenmus/v5.1.x

« back to all changes in this revision

Viewing changes to src/graphic/GMObject.cpp

  • Committer: cecilios
  • Date: 2008-09-13 17:53:40 UTC
  • Revision ID: svn-v4:2587a929-2f0e-0410-ae78-fe6f687d5efe:trunk:387

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include "../app/global.h"
36
36
#include "GMObject.h"
37
37
#include "BoxScore.h"
 
38
#include "Handlers.h"
38
39
#include "../app/Paper.h"
39
40
#include "../score/StaffObj.h"
40
41
#include "../app/ScoreCanvas.h"
71
72
        m_fSelected = false;
72
73
    m_fSelectable = fSelectable;
73
74
        m_fLeftDraggable = fDraggable;
 
75
        m_pHandlers = (std::list<lmHandler*>*)NULL;
74
76
}
75
77
 
76
78
lmGMObject::~lmGMObject()
77
79
{
 
80
    //delete handlers
 
81
        if (m_pHandlers)
 
82
        {
 
83
                std::list<lmHandler*>::iterator it;
 
84
                for (it = m_pHandlers->begin(); it != m_pHandlers->end(); ++it)
 
85
                        delete *it;
 
86
                delete m_pHandlers;
 
87
        }
78
88
}
79
89
 
80
90
bool lmGMObject::BoundsContainsPoint(lmUPoint& pointL)
81
91
{
82
 
    //returns true if point received is within the limits of this Box
 
92
    //returns true if point received is within the limits of this object bounds
 
93
 
83
94
    return GetBounds().Contains(pointL);
84
 
 
 
95
}
 
96
 
 
97
bool lmGMObject::SelRectContainsPoint(lmUPoint& pointL)
 
98
{
 
99
    //returns true if point received is within the limits of this object
 
100
    //selection rectangle
 
101
 
 
102
    return GetSelRectangle().Contains(pointL);
85
103
}
86
104
 
87
105
void lmGMObject::DrawBounds(lmPaper* pPaper, wxColour color)
200
218
    else
201
219
        pBS->RemoveFromSelection(this);
202
220
}
 
221
void lmGMObject::AddHandler(lmHandler* pHandler)
 
222
{
 
223
        if (!m_pHandlers)
 
224
        {
 
225
                m_pHandlers = new std::list<lmHandler*>();
 
226
            m_itHandler = m_pHandlers->begin();
 
227
        }
 
228
 
 
229
    m_pHandlers->push_back(pHandler);
 
230
}
 
231
 
 
232
lmHandler* lmGMObject::GetFirstHandler()
 
233
{
 
234
        wxASSERT(m_pHandlers);
 
235
    m_itHandler = m_pHandlers->begin();
 
236
    if (m_itHandler == m_pHandlers->end())
 
237
        return (lmHandler*)NULL;
 
238
 
 
239
    return *m_itHandler;
 
240
}
 
241
 
 
242
lmHandler* lmGMObject::GetNextHandler()
 
243
{
 
244
    //advance to next one
 
245
    ++m_itHandler;
 
246
    if (m_itHandler != m_pHandlers->end())
 
247
        return *m_itHandler;
 
248
 
 
249
    //no more items
 
250
    return (lmHandler*)NULL;
 
251
}
 
252
 
 
253
void lmGMObject::DrawHandlers(lmPaper* pPaper)
 
254
{
 
255
    //render handlers for selected objects
 
256
    if (m_pHandlers)    // && m_fSelected)
 
257
    {
 
258
        wxColour color = *wxRED;      //TODO User options
 
259
                std::list<lmHandler*>::iterator it;
 
260
                for (it = m_pHandlers->begin(); it != m_pHandlers->end(); ++it)
 
261
            (*it)->Render(pPaper, color);
 
262
    }
 
263
}
203
264
 
204
265
 
205
266
 
238
299
    //loop to look up in the shapes collection
239
300
        for(int i=0; i < (int)m_Shapes.size(); i++)
240
301
    {
241
 
        if (m_Shapes[i]->BoundsContainsPoint(pointL))
 
302
        if (m_Shapes[i]->IsSelectable() && m_Shapes[i]->SelRectContainsPoint(pointL))
242
303
                        return m_Shapes[i];    //found
243
304
    }
244
305