~ubuntu-branches/ubuntu/wily/ginkgocadx/wily-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/main/managers/widgetsmanager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Tille
  • Date: 2011-05-02 08:09:26 UTC
  • Revision ID: james.westby@ubuntu.com-20110502080926-bql5wep49c7hg91t
Tags: upstream-2.4.1.1
ImportĀ upstreamĀ versionĀ 2.4.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  
 
3
 *  $Id: widgetsmanager.cpp 3754 2011-04-25 07:11:36Z tovar $
 
4
 *  Ginkgo CADx Project
 
5
 *
 
6
 *  Copyright 2008-10 MetaEmotion S.L. All rights reserved.
 
7
 *  http://ginkgo-cadx.com
 
8
 *
 
9
 *  This file is licensed under LGPL v3 license.
 
10
 *  See License.txt for details
 
11
 *
 
12
 *
 
13
 */
 
14
//#define _GINKGO_TRACE
 
15
 
 
16
#include <wx/wx.h>
 
17
#include <wx/menu.h>
 
18
#include <wx/image.h>
 
19
#include <wx/timer.h>
 
20
 
 
21
#include <api/globals.h>
 
22
#include <api/icontexto.h>
 
23
#include <api/iwidgetsrenderer.h>
 
24
 
 
25
#include <eventos/eventosginkgo.h>
 
26
 
 
27
#include <api/westilo.h>
 
28
#include <main/entorno.h>
 
29
#include <main/controllers/controladoreventos.h>
 
30
#include <widgets/wanotacionesquina.h>
 
31
#include <widgets/wanotacionposicion.h>
 
32
 
 
33
#include "widgetsmanager.h"
 
34
 
 
35
#include <resources/ginkgoresourcemanager.h>
 
36
 
 
37
#include <cairo/cairo.h>
 
38
 
 
39
#include <vtkginkgoimageviewer.h>
 
40
 
 
41
class TimerAnimation : public wxTimer
 
42
{
 
43
public:
 
44
        TimerAnimation(GNC::GCS::IWidgetsManager* pManager){
 
45
                m_pManager = pManager;
 
46
                m_Frecuencia = 20.0f;
 
47
        }
 
48
 
 
49
        ~TimerAnimation() {}
 
50
 
 
51
        virtual void Notify(){
 
52
                m_pManager->TickAnimation(m_Frecuencia);
 
53
                //std::cout << "Tick()" << std::endl;
 
54
                m_pManager->Render();
 
55
        }
 
56
 
 
57
        void Enable()
 
58
        {
 
59
                if (IsRunning()) {
 
60
                        Stop();
 
61
                }
 
62
                Start((int)( 1000.0f * (1.0f/m_Frecuencia) ) );
 
63
        }
 
64
 
 
65
        void Disable()
 
66
        {
 
67
                if (IsRunning()) {
 
68
                        Stop();
 
69
                }
 
70
        }
 
71
protected:
 
72
        GNC::GCS::IWidgetsManager* m_pManager;
 
73
        double                     m_Frecuencia;
 
74
};
 
75
 
 
76
GNC::WidgetsManager::WidgetsManager(GNC::GCS::IVista* pVista):GNC::GCS::IWidgetsManager(pVista) {
 
77
        m_pRendererActivo = NULL;
 
78
        m_cursor = GNC::GCS::Widgets::CUR_FLECHA;
 
79
        m_mouseDerechoDown = false;
 
80
        m_mouseIzquierdoDown = false;
 
81
        m_pTimerAnimation = new TimerAnimation(this);
 
82
}
 
83
 
 
84
GNC::WidgetsManager::~WidgetsManager() {
 
85
        if (m_pTimerAnimation != NULL) {
 
86
                delete m_pTimerAnimation;
 
87
                m_pTimerAnimation = NULL;
 
88
        }
 
89
 
 
90
        for (GNC::GCS::ListaRenderers::iterator itr = m_Renderers.begin(); itr != m_Renderers.end(); itr++) {
 
91
                GNC::GCS::IWidgetsRenderer* pRenderer = *itr;
 
92
                pRenderer->WSetCurrent();
 
93
                for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++)
 
94
                {
 
95
                        GNC::GCS::Widgets::IWidget* w = (*it);
 
96
                        if(w->ReservaRecursos()) {
 
97
                                w->LiberarRecursos(pRenderer);
 
98
                        }
 
99
                }
 
100
        }
 
101
 
 
102
        GNC::GCS::ListaRenderers copia(m_Renderers); // Porque los renderers invocaran a EliminarRenderer de esta misma instancia;
 
103
 
 
104
        for (GNC::GCS::ListaRenderers::iterator it = copia.begin(); it != copia.end(); it++)
 
105
        {
 
106
                GNC::GCS::IWidgetsRenderer* renderer = *it;
 
107
 
 
108
                renderer->SetManager(NULL);
 
109
        }
 
110
 
 
111
        m_Widgets.clear();
 
112
 
 
113
}
 
114
 
 
115
void GNC::WidgetsManager::TickAnimation(double freq)
 
116
{
 
117
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
118
                GNC::GCS::Widgets::IWidget* w = *it;
 
119
                if (!w->EstaOculto()) {
 
120
                        w->TickAnimation(freq);
 
121
                }
 
122
        }
 
123
}
 
124
 
 
125
void GNC::WidgetsManager::EnableAnimation()
 
126
{
 
127
        m_pTimerAnimation->Enable();
 
128
}
 
129
 
 
130
void GNC::WidgetsManager::DisableAnimation()
 
131
{
 
132
        m_pTimerAnimation->Disable();
 
133
}
 
134
 
 
135
inline void GNC::WidgetsManager::ModificarRenderersDeWidget(GNC::GCS::Widgets::IWidget* w)
 
136
{
 
137
        if (w != NULL && !w->EsTopLevel()) {
 
138
                for (GNC::GCS::ListaRenderers::iterator itr = m_Renderers.begin(); itr != m_Renderers.end(); itr++) {
 
139
                        GNC::GCS::IWidgetsRenderer* ren = *itr;
 
140
                        if (w->GetVID() != -1 && w->GetVID() == ren->GetVID()) {
 
141
                                ren->Modificar(true);
 
142
                        }
 
143
                }
 
144
        }
 
145
}
 
146
 
 
147
//----------------------------------------------------------------------------------------------------
 
148
//region "Interfaz especifica"
 
149
 
 
150
void GNC::WidgetsManager::RenderPrivate(GNC::GCS::Contexto3D* c)
 
151
{
 
152
        glPushAttrib(GL_ENABLE_BIT);
 
153
        bool widgetIluminado = false;
 
154
        // Primera pasada: widgets normales.
 
155
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
156
                GNC::GCS::Widgets::IWidget* w = *it;
 
157
                if (!w->EsTopLevel() && (w->GetVID() == c->GetRenderer()->GetVID()) ) {
 
158
                        w->Render(c);
 
159
                        w->Modificar(false);
 
160
                }
 
161
                widgetIluminado = widgetIluminado || (!w->EstaOculto()&& w->EstaIluminado());
 
162
        }
 
163
 
 
164
        // Segunda pasada: widgets toplevel.
 
165
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
166
                GNC::GCS::Widgets::IWidget* w = *it;
 
167
                if (w->EsTopLevel()) {
 
168
                        w->Render(c);
 
169
                }
 
170
        }
 
171
 
 
172
        if (c->GetRenderer() == m_pRendererActivo) {
 
173
                if (m_pBuilder != NULL) {
 
174
                        m_pBuilder->Render(c);
 
175
                }
 
176
        }
 
177
 
 
178
        {
 
179
                GNC::GCS::Vector boundingBox;
 
180
 
 
181
                // Tercera pasada: dibujado de overlays
 
182
                for (IteradorListaWidgets it = m_Widgets.begin(); boundingBox.EsNulo() && it != m_Widgets.end(); it++)
 
183
                {
 
184
                        GNC::GCS::Widgets::IWidget* w = (*it);
 
185
                        if(!w->EstaOculto() && w->EstaIluminado() && (w->GetVID() == c->GetRenderer()->GetVID()) ){
 
186
                                if (m_pRendererActivo != NULL) {
 
187
                                        m_pRendererActivo->ImprimirOverlay(w, c, boundingBox);
 
188
                                }
 
189
                        }
 
190
                }
 
191
 
 
192
                if (m_pBuilder != NULL) {
 
193
                        if (!boundingBox.EsNulo()) {
 
194
                                if (m_pRendererActivo != NULL) {
 
195
                                        m_pRendererActivo->ImprimirOverlay(m_pBuilder, c, boundingBox);
 
196
                                }
 
197
                        }
 
198
                }
 
199
        }
 
200
 
 
201
        //cursor
 
202
        if(widgetIluminado)
 
203
        {
 
204
                //encima de un widget selecc e iluminado => si esta pulsando el boton derecho moviendose, si no pues no
 
205
                if(m_mouseIzquierdoDown) {
 
206
                        SetCursor(GNC::GCS::Widgets::CUR_MANO_CERRADA);
 
207
                        //std::cout << "WIluminado: IZDown: Mano Cerrada " << std::endl;
 
208
                } else {
 
209
                        SetCursor(GNC::GCS::Widgets::CUR_MANO_ABIERTA);
 
210
                        //std::cout << "WIluminado !IZDown: Mano Abierta " << std::endl;
 
211
                }
 
212
        } else {
 
213
                //si esta haciendo pam
 
214
                if(m_mouseDerechoDown) {
 
215
                        //std::cout << "!WIluminado: DERDown: Mano Cerrada " << std::endl;
 
216
                        SetCursor(GNC::GCS::Widgets::CUR_MANO_CERRADA);
 
217
                } else {
 
218
                        //si no se lo pedimos al builder
 
219
                        if(m_pBuilder != NULL && m_pBuilder->GetCursor() != GNC::GCS::Widgets::CUR_INVALIDO){
 
220
                                //std::cout << "!WIluminado: !DERDown: Builder cursor " << std::endl;
 
221
                                SetCursor(m_pBuilder->GetCursor());
 
222
                        } else {
 
223
                                //y si no pues si esta pulsando el derecho es que esta haciendo pan
 
224
                                //std::cout << "!WIluminado: !DERDown: Flecha" << std::endl;
 
225
                                SetCursor(GNC::GCS::Widgets::CUR_FLECHA);
 
226
                        }
 
227
                }
 
228
        }
 
229
 
 
230
        c->GetRenderer()->Modificar(false);
 
231
 
 
232
        glPopAttrib();
 
233
}
 
234
 
 
235
void GNC::WidgetsManager::Render() {
 
236
 
 
237
        bool seleccionEnActual = false;
 
238
        bool seleccionEnOtro = false;
 
239
 
 
240
        // Primera pasada: Widgets
 
241
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
242
                GNC::GCS::Widgets::IWidget* w = *it;
 
243
                if (!w->EsTopLevel() && !w->EstaOculto()) {
 
244
                        if (m_pRendererActivo) { // Si hay renderer activo, comprobamos las selecciones.
 
245
                                if (w->EstaSeleccionado()) {
 
246
                                        if (w->GetVID() == m_pRendererActivo->GetVID()) {
 
247
                                                seleccionEnActual = true;
 
248
                                        }
 
249
                                        else {
 
250
                                                seleccionEnOtro = true;
 
251
                                        }
 
252
                                }
 
253
                        }
 
254
                        if (w->EstaModificado()) {
 
255
                                w->Modificar(false);
 
256
                                ModificarRenderersDeWidget(w);
 
257
                        }
 
258
                }
 
259
        }
 
260
 
 
261
        if (seleccionEnActual && seleccionEnOtro) {
 
262
                // Segunda pasada opcional: Deseleccion de selecciones en renderers no activos
 
263
                for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
264
                        GNC::GCS::Widgets::IWidget* w = *it;
 
265
                        if (!w->EsTopLevel() && !w->EstaOculto()) {
 
266
                                if (m_pRendererActivo) { // Si hay renderer activo, comprobamos las selecciones.
 
267
                                        if (w->EstaSeleccionado()) {                                            
 
268
                                                if (w->GetVID() != m_pRendererActivo->GetVID()) {
 
269
                                                        w->Seleccionar(false);
 
270
                                                        w->Modificar(false);
 
271
                                                        ModificarRenderersDeWidget(w);
 
272
                                                }
 
273
                                        }
 
274
                                }
 
275
                        }
 
276
                }
 
277
        }
 
278
 
 
279
        for (GNC::GCS::ListaRenderers::iterator it = m_Renderers.begin(); it != m_Renderers.end(); it++) {
 
280
                GNC::GCS::IWidgetsRenderer* ren = *it;
 
281
                if (ren->EstaModificado()) {
 
282
                        GTRACE("Renderer[" << ren->GetVID() << "] modificado. Rendering...");
 
283
                        //si el renderer es el activo, provoca un update inmediato, sino solo un refresh que harĆ” un update cuando pueda
 
284
                        ren->PostRender(ren == m_pRendererActivo);
 
285
                        ren->Modificar(false);
 
286
                }
 
287
        }
 
288
}
 
289
 
 
290
void GNC::WidgetsManager::OffScreenRender(GNC::GCS::Contexto3D* c)
 
291
{
 
292
 
 
293
        // Primera pasada: Widgets normales
 
294
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
295
                GNC::GCS::Widgets::IWidget* w = *it;
 
296
                if (!w->EstaOculto() && !w->EsTopLevel() && w->GetVID() == c->OVID) {
 
297
                        w->OffscreenRender(c);
 
298
                }
 
299
        }
 
300
 
 
301
        // Primera pasada: Widgets top level
 
302
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
303
                GNC::GCS::Widgets::IWidget* w = *it;
 
304
                if (!w->EstaOculto() && w->EsTopLevel()) {
 
305
                        w->OffscreenRender(c);
 
306
                }
 
307
        }
 
308
}
 
309
 
 
310
void GNC::WidgetsManager::Modificado()
 
311
{
 
312
        if (m_pRendererActivo != NULL)
 
313
        {
 
314
                m_pRendererActivo->Modificar(true);
 
315
        }
 
316
}
 
317
 
 
318
void GNC::WidgetsManager::ModificadoPorWidget(GNC::GCS::Widgets::IWidget* w)
 
319
{
 
320
        this->ModificarRenderersDeWidget(w);
 
321
}
 
322
 
 
323
void GNC::WidgetsManager::OnMouseEvents(GNC::GCS::Eventos::EventoRaton& evento)
 
324
{
 
325
        evento.Skip(true);
 
326
 
 
327
        if (!evento.c->IsOk()) {
 
328
                std::cerr << "Adverencia: Render omitido: singularidad en contexto" << std::endl;
 
329
        }
 
330
 
 
331
        //pillamos boton derecho e izquierdo down-up
 
332
        if (evento.ButtonDown(GNC::GCS::Eventos::EventoRaton::EB_IZQUIERDO)) {
 
333
                m_mouseIzquierdoDown = true;
 
334
        } else if(evento.ButtonUp(GNC::GCS::Eventos::EventoRaton::EB_IZQUIERDO)){
 
335
                m_mouseIzquierdoDown = false;
 
336
        } else if(evento.ButtonDown(GNC::GCS::Eventos::EventoRaton::EB_DERECHO)){
 
337
                m_mouseDerechoDown = true;
 
338
        } else if(evento.ButtonUp(GNC::GCS::Eventos::EventoRaton::EB_DERECHO)){
 
339
                m_mouseDerechoDown = false;
 
340
        }
 
341
 
 
342
        // Primera pasada: widgets toplevel.
 
343
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++)
 
344
        {
 
345
                GNC::GCS::Widgets::IWidget* w = (*it);
 
346
                if(!w->EstaOculto() && w->EsTopLevel() && !w->IgnoraEventos()){
 
347
                        w->OnMouseEvents(evento);
 
348
                        if (w->EstaModificado()) {
 
349
                                Modificado();
 
350
                                if (w->RequiereNotificarCambios()) {
 
351
                                        w->NotificarCambios(false);
 
352
                                        NotificarModificacion(w);
 
353
                                }
 
354
                                w->Modificar(false);
 
355
                        }                       
 
356
                }
 
357
        }
 
358
        // Segunda pasada: widgets normales.
 
359
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++)
 
360
        {
 
361
                GNC::GCS::Widgets::IWidget* w = (*it);
 
362
                if(!w->EstaOculto() && !w->EsTopLevel() && !w->IgnoraEventos() && ( w->GetVID() == evento.c->GetRenderer()->GetVID())){
 
363
                        w->OnMouseEvents(evento);
 
364
                        if (w->EstaModificado()) {
 
365
                                Modificado();
 
366
                                if (w->RequiereNotificarCambios()) {
 
367
                                        w->NotificarCambios(false);
 
368
                                        NotificarModificacion(w);
 
369
                                }
 
370
                                w->Modificar(false);
 
371
                        }
 
372
                        if (w->EstaIluminado() && ( evento.LeftUp() ||evento.LeftDown() )) { // Si el widget esta iluminado y este evento es up/down del boton izquierdo, forzamos render para cambiar el cursor.
 
373
                                Modificado();
 
374
                        }
 
375
                }
 
376
        }
 
377
 
 
378
        if (m_pBuilder != NULL && evento.GetSkipped()) {
 
379
                m_pBuilder->OnMouseEvents(evento);
 
380
        }
 
381
 
 
382
        if (evento.GetSkipped()) {
 
383
                DefaultMouseEventProcess(evento);
 
384
        }
 
385
        if (m_pRendererActivo != NULL && m_pRendererActivo->EstaModificado()) {
 
386
                Render();
 
387
        }
 
388
}
 
389
 
 
390
void GNC::WidgetsManager::OnKeyEvents(GNC::GCS::Eventos::EventoTeclado& evento)
 
391
{
 
392
        evento.Skip(true);
 
393
 
 
394
        /* Paso de auto-borrado (si lo soporta el widget) */
 
395
        if (evento.GetKeyCode() == WXK_DELETE || evento.GetKeyCode() == WXK_BACK) {
 
396
                GNC::GCS::ListaWidgets lw;
 
397
                for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++)
 
398
                {
 
399
                        GNC::GCS::Widgets::IWidget* w = (*it);
 
400
 
 
401
                        if(!w->EstaOculto() && w->EstaSeleccionado() && w->SoportaAutoBorrado() && (w->GetVID() == -1 || w->GetVID() == evento.c->GetRenderer()->GetVID())) {
 
402
                                lw.push_back(w);
 
403
 
 
404
                        }
 
405
                }
 
406
                for (IteradorListaWidgets it = lw.begin(); it != lw.end(); it++){
 
407
                        EliminarWidget(*it, true);
 
408
                        Modificado();
 
409
                }
 
410
        }
 
411
        else if (evento.GetKeyCode() == 'r' || evento.GetKeyCode() == 'R') {
 
412
                for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++)
 
413
                {
 
414
                        GNC::GCS::Widgets::IWidget* w = (*it);
 
415
                        w->Modificar(true);
 
416
                }
 
417
        }
 
418
 
 
419
        if (m_pBuilder != NULL) {
 
420
                m_pBuilder->OnKeyEvents(evento);
 
421
        }
 
422
 
 
423
        // Primera pasada: widgets toplevel.
 
424
        for (IteradorListaWidgets it = m_Widgets.begin(); evento.GetSkipped() && it != m_Widgets.end(); it++)
 
425
        {
 
426
                GNC::GCS::Widgets::IWidget* w = (*it);
 
427
                if(!w->EstaOculto() && w->EsTopLevel() && !w->IgnoraEventos() && (w->GetVID() == evento.c->GetRenderer()->GetVID())){
 
428
                        w->OnKeyEvents(evento);
 
429
                        if (w->EstaModificado()) {
 
430
                                Modificado();
 
431
                                if (w->RequiereNotificarCambios()) {
 
432
                                        w->NotificarCambios(false);
 
433
                                        NotificarModificacion(w);
 
434
                                }
 
435
                        }
 
436
                }
 
437
        }
 
438
        // Segunda pasada: widgets normales.
 
439
        for (IteradorListaWidgets it = m_Widgets.begin(); evento.GetSkipped() && it != m_Widgets.end(); it++)
 
440
        {
 
441
                GNC::GCS::Widgets::IWidget* w = (*it);
 
442
                if(!w->EstaOculto() && !w->EsTopLevel() && !w->IgnoraEventos() && (w->GetVID() == evento.c->GetRenderer()->GetVID())){
 
443
                        w->OnKeyEvents(evento);
 
444
                        if (w->EstaModificado()) {
 
445
                                Modificado();
 
446
                                if (w->RequiereNotificarCambios()) {
 
447
                                        w->NotificarCambios(false);
 
448
                                        NotificarModificacion(w);
 
449
                                }
 
450
                        }
 
451
                }
 
452
        }
 
453
 
 
454
        if (evento.GetSkipped()) {
 
455
                DefaultKeyEventProcess(evento);
 
456
        }
 
457
        Render();
 
458
}
 
459
 
 
460
void GNC::WidgetsManager::DefaultMouseEventProcess(GNC::GCS::Eventos::EventoRaton& evento)
 
461
{
 
462
        /* Paso de mostrar menu si procede */
 
463
        if (evento.ButtonUp(GNC::GCS::Eventos::EventoRaton::EB_DERECHO)) {
 
464
 
 
465
                //std::cout << "DerUp! ĀæRender?" << std::endl;
 
466
 
 
467
                SetCursor(GNC::GCS::Widgets::CUR_MANO_ABIERTA);
 
468
 
 
469
                GNC::GCS::ListaWidgets lw;
 
470
 
 
471
                for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++)
 
472
                {
 
473
                        GNC::GCS::Widgets::IWidget* w = (*it);
 
474
                        if(!w->EstaOculto() && w->EstaSeleccionado() && !w->IgnoraEventos() && (w->GetVID() == -1 || w->GetVID() == evento.c->GetRenderer()->GetVID())){
 
475
                                lw.push_back(w);
 
476
                        }
 
477
                }
 
478
 
 
479
                if(lw.size()>0) {
 
480
                        //comprobamos si alguno de los seleccionados valida el hittest
 
481
                        for (IteradorListaWidgets it = lw.begin(); it != lw.end(); it++)
 
482
                        {
 
483
                                GNC::GCS::Widgets::IWidget* w = (*it);
 
484
                                if(w->HitTest(evento.iP.x, evento.iP.y, evento.c->RelacionImagenPantalla().NormaInfinito())){
 
485
                                        wxMenu menu;
 
486
                                        if(lw.size() == 1){
 
487
                                                //se meten las opciones que pueda aportar el widget
 
488
                                                w->GetMenuContextual(&menu, evento.c->pWindow );
 
489
                                                if(menu.GetMenuItemCount()>0) {
 
490
                                                        menu.AppendSeparator();
 
491
                                                }
 
492
                                        }
 
493
                                        GetMenuContextual(&menu);
 
494
                                        //en este caso hay varios seleccionados pues se muestra el menu comun...
 
495
                                        evento.c->pWindow->PopupMenu(&menu,wxPoint(evento.sX, evento.sY));
 
496
                                        if(m_pBuilder != NULL && m_pBuilder->GetCursor() != GNC::GCS::Widgets::CUR_INVALIDO){
 
497
                                                SetCursor(m_pBuilder->GetCursor());
 
498
                                        } else {
 
499
                                                //y si no pues si esta pulsando el derecho es que esta haciendo pan
 
500
                                                SetCursor(GNC::GCS::Widgets::CUR_FLECHA);
 
501
                                        }
 
502
                                        ConsumirEvento();
 
503
                                        break;
 
504
                                }
 
505
                        }
 
506
                }
 
507
 
 
508
                if(!(EventoConsumido())){
 
509
                        if(lw.size()>0){
 
510
                                //se deseleccionan los widgets seleccionados
 
511
                                for (IteradorListaWidgets it = lw.begin(); it != lw.end(); it++)
 
512
                                {
 
513
                                        GNC::GCS::Widgets::IWidget* w = (*it);
 
514
                                        w->Seleccionar(false);
 
515
                                }
 
516
                        }
 
517
                        //hay que buscar si algun widget valida el hittest, en ese caso se selecciona y se muestra el menu
 
518
                        GNC::GCS::Widgets::IWidget* widgetMenu = NULL;
 
519
                        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++)
 
520
                        {
 
521
                                GNC::GCS::Widgets::IWidget* w = (*it);
 
522
                                if(!w->EstaOculto() && !w->IgnoraEventos() && (w->GetVID() == -1 || w->GetVID() == evento.c->GetRenderer()->GetVID()) && w->HitTest(evento.iP.x, evento.iP.y, evento.c->RelacionImagenPantalla().NormaInfinito())){
 
523
                                        widgetMenu = w;
 
524
                                        break;
 
525
                                }
 
526
                        }
 
527
                        if(widgetMenu != NULL) {
 
528
                                widgetMenu->Seleccionar(true);
 
529
                                wxMenu menu;
 
530
                                //se meten las opciones que pueda aportar el widget
 
531
                                widgetMenu->GetMenuContextual(&menu, evento.c->pWindow );
 
532
                                if(menu.GetMenuItemCount()>0) {
 
533
                                        menu.AppendSeparator();
 
534
                                }
 
535
 
 
536
                                GetMenuContextual(&menu);
 
537
 
 
538
                                //en este caso hay varios seleccionados pues se muestra el menu comun...
 
539
                                evento.c->pWindow->PopupMenu(&menu, wxPoint(evento.sX, evento.sY));
 
540
                                if(m_pBuilder != NULL && m_pBuilder->GetCursor() != GNC::GCS::Widgets::CUR_INVALIDO){
 
541
                                        SetCursor(m_pBuilder->GetCursor());
 
542
                                } else {
 
543
                                        //y si no pues si esta pulsando el derecho es que esta haciendo pan
 
544
                                        SetCursor(GNC::GCS::Widgets::CUR_FLECHA);
 
545
                                }
 
546
                                ConsumirEvento();
 
547
                        }
 
548
                        else {
 
549
                                if(m_pBuilder != NULL && m_pBuilder->GetCursor() != GNC::GCS::Widgets::CUR_INVALIDO){
 
550
                                        SetCursor(m_pBuilder->GetCursor());
 
551
                                } else {
 
552
                                        //y si no pues si esta pulsando el derecho es que esta haciendo pan
 
553
                                        SetCursor(GNC::GCS::Widgets::CUR_FLECHA);
 
554
                                }
 
555
 
 
556
                        }
 
557
                }
 
558
        } else {
 
559
                evento.Skip(true);
 
560
        }
 
561
}
 
562
 
 
563
void GNC::WidgetsManager::DefaultKeyEventProcess(GNC::GCS::Eventos::EventoTeclado& evento)
 
564
{
 
565
        evento.Skip(true);
 
566
}
 
567
 
 
568
void GNC::WidgetsManager::PropagarHitTestSeleccion(GNC::GCS::Vector* vertices, int numVertices)
 
569
{
 
570
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++)
 
571
        {
 
572
                GNC::GCS::Widgets::IWidget* w = (*it);
 
573
                if(!w->EstaOculto() && !w->IgnoraEventos() && w->HitTest(vertices, numVertices)){
 
574
                        w->Seleccionar(true);
 
575
                }
 
576
        }
 
577
}
 
578
 
 
579
//endregion
 
580
 
 
581
//----------------------------------------------------------------------------------------------------
 
582
//region "Interfaz de registro de Renderers"
 
583
 
 
584
void GNC::WidgetsManager::SetRendererActivo(GNC::GCS::IWidgetsRenderer* pRenderer)
 
585
{
 
586
        m_pRendererActivo = pRenderer;
 
587
}
 
588
 
 
589
void GNC::WidgetsManager::InsertarRenderer(GNC::GCS::IWidgetsRenderer* pRenderer)
 
590
{
 
591
        bool notfound = true;
 
592
        for (GNC::GCS::ListaRenderers::iterator it = m_Renderers.begin(); notfound && (it != m_Renderers.end()); it++)
 
593
        {
 
594
                GNC::GCS::IWidgetsRenderer* renderer = *it;
 
595
 
 
596
                if (pRenderer == renderer)
 
597
                {
 
598
                        notfound = false;
 
599
                }
 
600
        }
 
601
        if (notfound == true) {
 
602
                m_Renderers.push_back(pRenderer);
 
603
        }
 
604
 
 
605
}
 
606
 
 
607
void GNC::WidgetsManager::EliminarRenderer(GNC::GCS::IWidgetsRenderer* pRenderer)
 
608
{
 
609
        bool notfound = true;
 
610
        GNC::GCS::ListaRenderers::iterator itpos = m_Renderers.end();
 
611
        for (GNC::GCS::ListaRenderers::iterator it = m_Renderers.begin(); notfound && (it != m_Renderers.end()); it++)
 
612
        {
 
613
                GNC::GCS::IWidgetsRenderer* renderer = *it;
 
614
 
 
615
                if (pRenderer == renderer)
 
616
                {
 
617
                        if (renderer == m_pRendererActivo) {
 
618
                                m_pRendererActivo = NULL;
 
619
                        }
 
620
                        notfound = false;
 
621
                        itpos = it;
 
622
                }
 
623
        }
 
624
        if (itpos != m_Renderers.end())
 
625
        {
 
626
                m_Renderers.erase(itpos);
 
627
        }
 
628
        if (m_pRendererActivo == NULL && m_Renderers.size() > 0) {
 
629
                m_pRendererActivo = m_Renderers.front();
 
630
        }
 
631
}
 
632
 
 
633
 
 
634
 
 
635
void GNC::WidgetsManager::LiberarRecursos(GNC::GCS::IWidgetsRenderer* pRenderer)
 
636
{
 
637
        pRenderer->WSetCurrent();
 
638
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++)
 
639
        {
 
640
                (*it)->LiberarRecursos(pRenderer);
 
641
        }
 
642
}
 
643
 
 
644
//endregion
 
645
 
 
646
//----------------------------------------------------------------------------------------------------
 
647
//region "Interfaz de registro de IWidget's"
 
648
 
 
649
void GNC::WidgetsManager::InsertarWidget(GNC::GCS::Widgets::IWidget* pWidget, bool propagarEvento)
 
650
{
 
651
        m_Widgets.push_back(pWidget);
 
652
        if (propagarEvento) {
 
653
                NotificarCreacion(pWidget);
 
654
        }
 
655
}
 
656
 
 
657
void GNC::WidgetsManager::EliminarWidget(GNC::GCS::Widgets::IWidget* pWidget, bool propagarEvento)
 
658
{
 
659
        IteradorListaWidgets it;
 
660
 
 
661
        for (it = m_Widgets.begin(); it != m_Widgets.end() && (*it) != pWidget; it++);
 
662
 
 
663
        if (it != m_Widgets.end()) {
 
664
                if (propagarEvento) {
 
665
                        NotificarDestruccion(pWidget);
 
666
                }
 
667
                if(pWidget->ReservaRecursos()) {
 
668
                        for (GNC::GCS::ListaRenderers::iterator itr = m_Renderers.begin(); itr != m_Renderers.end(); itr++)
 
669
                        {
 
670
                                GNC::GCS::IWidgetsRenderer* pRenderer = *itr;
 
671
                                pRenderer->WSetCurrent();
 
672
                                pWidget->LiberarRecursos(pRenderer);
 
673
                        }
 
674
 
 
675
                }
 
676
                m_Widgets.erase(it);
 
677
        }
 
678
        delete pWidget;
 
679
}
 
680
 
 
681
void GNC::WidgetsManager::EliminarWidget(GNC::GCS::IWidgetsManager::IteradorListaWidgets& it, bool propagarEvento)
 
682
{
 
683
        if (it != m_Widgets.end()) {
 
684
                GNC::GCS::Widgets::IWidget* w = (*it);
 
685
                if (propagarEvento) {
 
686
                        NotificarDestruccion(w);
 
687
                }
 
688
                if(w->ReservaRecursos()) {
 
689
                        for (GNC::GCS::ListaRenderers::iterator itr = m_Renderers.begin(); itr != m_Renderers.end(); itr++)
 
690
                        {
 
691
                                GNC::GCS::IWidgetsRenderer* pRenderer = *itr;
 
692
                                pRenderer->WSetCurrent();
 
693
                                w->LiberarRecursos(pRenderer);
 
694
                        }
 
695
                }
 
696
                delete w;
 
697
                m_Widgets.erase(it);
 
698
        }
 
699
}
 
700
 
 
701
void GNC::WidgetsManager::EliminarTodosLosWidgets(bool propagarEventos)
 
702
{
 
703
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
704
                GNC::GCS::Widgets::IWidget* w = (*it);
 
705
                if (propagarEventos) {
 
706
                        NotificarDestruccion(w);
 
707
                }
 
708
                if(w->ReservaRecursos()) {
 
709
                        for (GNC::GCS::ListaRenderers::iterator itr = m_Renderers.begin(); itr != m_Renderers.end(); itr++)
 
710
                        {
 
711
                                GNC::GCS::IWidgetsRenderer* pRenderer = *itr;
 
712
                                pRenderer->WSetCurrent();
 
713
                                w->LiberarRecursos(pRenderer);
 
714
                        }
 
715
                }
 
716
                delete w;
 
717
        }
 
718
        m_Widgets.clear();
 
719
}
 
720
 
 
721
void GNC::WidgetsManager::OcultarTodosLosWidgets(bool ocultar, long GID){
 
722
 
 
723
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
724
                GNC::GCS::Widgets::IWidget* w = (*it);
 
725
                if(w->GetGID() == GID){
 
726
                        if(ocultar && w->ReservaRecursos()) {
 
727
                                for (GNC::GCS::ListaRenderers::iterator itr = m_Renderers.begin(); itr != m_Renderers.end(); itr++)
 
728
                                {
 
729
                                        GNC::GCS::IWidgetsRenderer* pRenderer = *itr;
 
730
                                        pRenderer->WSetCurrent();
 
731
                                        w->LiberarRecursos(pRenderer);
 
732
                                }
 
733
                        }
 
734
                        w->Ocultar(ocultar);
 
735
                }
 
736
        }
 
737
}
 
738
 
 
739
void GNC::WidgetsManager::EliminarTodosLosWidgets(long GID)
 
740
{
 
741
        GNC::GCS::ListaWidgets listaEliminados;
 
742
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
743
                GNC::GCS::Widgets::IWidget* w = (*it);
 
744
                if(w->GetGID() == GID){
 
745
                        listaEliminados.push_back(w);
 
746
                }
 
747
        }
 
748
        for(IteradorListaWidgets it = listaEliminados.begin(); it!= listaEliminados.end(); it++) {
 
749
                EliminarWidget((*it));
 
750
        }
 
751
}
 
752
 
 
753
void GNC::WidgetsManager::OcultarWidgetsDeSubVista(bool /*ocultar*/, long /*vid*/)
 
754
{
 
755
        /*
 
756
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
757
                GNC::GCS::Widgets::IWidget* w = *it;
 
758
                if(w->GetVID() == vid){
 
759
                        if( w->EstaOculto() != ocultar ) {
 
760
                                if (ocultar && w->ReservaRecursos()) {
 
761
                                        for (ListaRenderers::iterator itr = m_Renderers.begin(); itr != m_Renderers.end(); itr++)
 
762
                                        {
 
763
                                                GNC::GCS::IWidgetsRenderer* pRenderer = *itr;
 
764
                                                pRenderer->WSetCurrent();
 
765
                                                w->LiberarRecursos(pRenderer);
 
766
                                        }
 
767
                                }
 
768
                                w->Ocultar(ocultar);
 
769
                                Modificado();
 
770
                        }
 
771
                }
 
772
        }
 
773
         */
 
774
}
 
775
 
 
776
GNC::GCS::ListaWidgets& GNC::WidgetsManager::GetListaWidgets()
 
777
{
 
778
        return m_Widgets;
 
779
}
 
780
 
 
781
void GNC::WidgetsManager::GetListaWidgetsSubVista(long vid, GNC::GCS::ListaWidgets& lista)
 
782
{
 
783
        for(GNC::GCS::IWidgetsManager::IteradorListaWidgets it = m_Widgets.begin(); it!= m_Widgets.end(); it++){
 
784
                if((*it)->GetVID() == vid){
 
785
                        lista.push_back((*it));
 
786
                }
 
787
        }
 
788
}
 
789
 
 
790
//endregion
 
791
 
 
792
//----------------------------------------------------------------------------------------------------
 
793
//endregion "Interfaz de Observadores"
 
794
 
 
795
void GNC::WidgetsManager::NotificarCreacion(GNC::GCS::Widgets::IWidget* pWidget)
 
796
{
 
797
 
 
798
        for (IteradorListaObservadores it = m_Observadores.begin(); it != m_Observadores.end(); it++) {
 
799
                GNC::GCS::Widgets::IObservadorWidget* pObservador = *it;
 
800
                //TODO hasta que no se adapten los observadores de las herramientas no se pondra esta linea que es la buena
 
801
                //if ((pObservador->VID == -1 || pObservador->VID == m_pRendererActivo->GetVID())&& pObservador->GID == pWidget->GetGID()) {
 
802
                if (pObservador->GID == pWidget->GetGID()) {
 
803
                //
 
804
                        pObservador->OnWidgetCreado(pWidget);
 
805
                }
 
806
        }
 
807
}
 
808
 
 
809
void GNC::WidgetsManager::NotificarDestruccion(GNC::GCS::Widgets::IWidget* pWidget)
 
810
{
 
811
 
 
812
        for (IteradorListaObservadores it = m_Observadores.begin(); it != m_Observadores.end(); it++) {
 
813
                GNC::GCS::Widgets::IObservadorWidget* pObservador = *it;
 
814
                //TODO hasta que no se adapten los observadores de las herramientas no se pondra esta linea que es la buena
 
815
                //if ((pObservador->VID == -1 || pObservador->VID == m_pRendererActivo->GetVID())&& pObservador->GID == pWidget->GetGID()) {
 
816
                if (pObservador->GID == pWidget->GetGID()) {
 
817
                //
 
818
                        pObservador->OnWidgetDestruido(pWidget);
 
819
                }
 
820
        }
 
821
}
 
822
 
 
823
void GNC::WidgetsManager::NotificarModificacion(GNC::GCS::Widgets::IWidget* pWidget)
 
824
{
 
825
 
 
826
        for (IteradorListaObservadores it = m_Observadores.begin(); it != m_Observadores.end(); it++) {
 
827
                GNC::GCS::Widgets::IObservadorWidget* pObservador = *it;
 
828
                //TODO hasta que no se adapten los observadores de las herramientas no se pondra esta linea que es la buena
 
829
                //if ((pObservador->VID == -1 || pObservador->VID == m_pRendererActivo->GetVID())&& pObservador->GID == pWidget->GetGID()) {
 
830
                if (pObservador->GID == pWidget->GetGID()) {
 
831
                //
 
832
                        pObservador->OnWidgetModificado(pWidget);
 
833
                }
 
834
        }
 
835
}
 
836
 
 
837
//endregion
 
838
 
 
839
//----------------------------------------------------------------------------------------------------
 
840
//region "Interfaz general"
 
841
void GNC::WidgetsManager::CrearWidgetAnotador(GNC::GCS::IAnotador* pAnotador)
 
842
{
 
843
        GNC::GCS::Widgets::WAnotador* pW = new GNC::GCS::Widgets::WAnotador(pAnotador,this,-1,"",-1);
 
844
        InsertarWidget(pW);
 
845
        GNC::GCS::Widgets::WAnotacionPosicion* pPosicion = new GNC::GCS::Widgets::WAnotacionPosicion(pAnotador,this,-1,"",-1);
 
846
        InsertarWidget(pPosicion);
 
847
}
 
848
 
 
849
void GNC::WidgetsManager::EnableAnotacionDinamica(bool /*enable*/)
 
850
{
 
851
        //buscamos los widgets anotadores y los establecemos el modo
 
852
        for( GNC::GCS::ListaWidgets::iterator it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
853
                GNC::GCS::Widgets::IWidget* w = *it;
 
854
                if (w->GetVID() == -1 && w->GetGID() == -1) {
 
855
                        //GNC::GCS::Widgets::WAnotador* pAnotador = dynamic_cast<GNC::GCS::Widgets::WAnotador*> (w);
 
856
                }
 
857
        }
 
858
}
 
859
 
 
860
void GNC::WidgetsManager::MostrarOcultarAnotador()
 
861
{
 
862
        //buscamos los widgets anotadores y los establecemos el modo
 
863
        for( GNC::GCS::ListaWidgets::iterator it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
864
                GNC::GCS::Widgets::IWidget* w = *it;
 
865
                if (w->GetVID() == -1 && w->GetGID() == -1) {
 
866
                        GNC::GCS::Widgets::WAnotador* pAnotador = dynamic_cast<GNC::GCS::Widgets::WAnotador*> (w);
 
867
                        if (pAnotador != NULL) {
 
868
                                pAnotador->Ocultar(!pAnotador->EstaOculto());
 
869
                        }
 
870
                }
 
871
        }
 
872
}
 
873
 
 
874
bool GNC::WidgetsManager::IsVisibleAnotador()
 
875
{
 
876
        for( GNC::GCS::ListaWidgets::iterator it = m_Widgets.begin(); it != m_Widgets.end(); it++) {
 
877
                GNC::GCS::Widgets::IWidget* w = *it;
 
878
                if (w->GetVID() == -1 && w->GetGID() == -1) {
 
879
                        GNC::GCS::Widgets::WAnotador* pAnotador = dynamic_cast<GNC::GCS::Widgets::WAnotador*> (w);
 
880
                        if (pAnotador != NULL) {
 
881
                                return !pAnotador->EstaOculto();
 
882
                        }
 
883
                }
 
884
        }
 
885
        return false;
 
886
}
 
887
//enderegion
 
888
 
 
889
//----------------------------------------------------------------------------------------------------
 
890
//region "Interfaz de acceso al sistema de eventos ginkgo"
 
891
 
 
892
void GNC::WidgetsManager::LanzarEventoCreacion(GNC::GCS::Widgets::IWidget* w)
 
893
{
 
894
        GNC::Entorno::Instance()->GetControladorEventos()->ProcesarEvento(new GNC::GCS::Eventos::EventoModificacionWidget(m_pVista,GNC::GCS::Eventos::EventoModificacionWidget::WidgetCreado, w));
 
895
}
 
896
 
 
897
void GNC::WidgetsManager::LanzarEventoModificacion(GNC::GCS::Widgets::IWidget* w)
 
898
{
 
899
        GNC::Entorno::Instance()->GetControladorEventos()->ProcesarEvento(new GNC::GCS::Eventos::EventoModificacionWidget(m_pVista,GNC::GCS::Eventos::EventoModificacionWidget::WidgetModificado, w));
 
900
}
 
901
 
 
902
void GNC::WidgetsManager::LanzarEventoDestruccion(GNC::GCS::Widgets::IWidget* w)
 
903
{
 
904
        GNC::Entorno::Instance()->GetControladorEventos()->ProcesarEvento(new GNC::GCS::Eventos::EventoModificacionWidget(m_pVista,GNC::GCS::Eventos::EventoModificacionWidget::WidgetDestruido, w));
 
905
}
 
906
 
 
907
GNC::GCS::IControladorEventos* GNC::WidgetsManager::GetControladorEventos() {
 
908
        return GNC::Entorno::Instance()->GetControladorEventos();
 
909
}
 
910
 
 
911
 
 
912
void GNC::WidgetsManager::ProcesarEvento(GNC::GCS::Eventos::IEvento* /*evt*/){
 
913
 
 
914
}
 
915
 
 
916
//endregion
 
917
 
 
918
void GNC::WidgetsManager::OnClickEnPropiedades(wxCommandEvent& )
 
919
{
 
920
        //eliminamos los widgets seleccionados que soporten autoborrar
 
921
        GNC::GCS::ListaWidgets lw;
 
922
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++)
 
923
        {
 
924
                GNC::GCS::Widgets::IWidget* w = (*it);
 
925
 
 
926
                if(!w->EstaOculto() && w->EstaSeleccionado()) {
 
927
                        lw.push_back(w);
 
928
                }
 
929
        }
 
930
        for (IteradorListaWidgets it = lw.begin(); it != lw.end(); it++){
 
931
                //mostrar propiedades de los widgets
 
932
                (*it)->MostrarPropiedades(GNC::Entorno::Instance()->GetVentanaRaiz());
 
933
        }
 
934
}
 
935
 
 
936
void GNC::WidgetsManager::OnClickEnEliminar(wxCommandEvent& )
 
937
{
 
938
        //eliminamos los widgets seleccionados que soporten autoborrar
 
939
        GNC::GCS::ListaWidgets lw;
 
940
        for (IteradorListaWidgets it = m_Widgets.begin(); it != m_Widgets.end(); it++)
 
941
        {
 
942
                GNC::GCS::Widgets::IWidget* w = (*it);
 
943
 
 
944
                if(!w->EstaOculto() && w->EstaSeleccionado() && w->SoportaAutoBorrado() ) {
 
945
                        lw.push_back(w);
 
946
 
 
947
                }
 
948
        }
 
949
        for (IteradorListaWidgets it = lw.begin(); it != lw.end(); it++){
 
950
                EliminarWidget(*it, true);
 
951
                Modificado();
 
952
        }
 
953
}
 
954
 
 
955
bool GNC::WidgetsManager::GetMenuContextual(wxMenu* menuContextual) const {
 
956
        wxMenuItem* pMenuEliminar = new wxMenuItem(menuContextual, -1, _("Delete"), _("Delete Widget"), wxITEM_NORMAL );
 
957
        menuContextual->Connect(pMenuEliminar->GetId(),(int)wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(WidgetsManager::OnClickEnEliminar),NULL,(wxEvtHandler*)this);
 
958
        #ifdef __WXMSW__
 
959
        pMenuEliminar->SetBitmaps( GinkgoResourcesManager::IconosMenus::GetIcoEliminarWidget());
 
960
        #else
 
961
        pMenuEliminar->SetBitmap(GinkgoResourcesManager::IconosMenus::GetIcoEliminarWidget());
 
962
        #endif
 
963
        menuContextual->Append(pMenuEliminar);
 
964
 
 
965
        menuContextual->AppendSeparator();
 
966
 
 
967
        wxMenuItem* pMenuPropiedades = new wxMenuItem(menuContextual, -1, _("Properties ..."), _("Widget Properties"), wxITEM_NORMAL );
 
968
        menuContextual->Connect(pMenuPropiedades->GetId(),(int)wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(WidgetsManager::OnClickEnPropiedades),NULL,(wxEvtHandler*)this);
 
969
        menuContextual->Append(pMenuPropiedades);
 
970
        return true;
 
971
}
 
972
 
 
973
void GNC::WidgetsManager::SetCursor(GNC::GCS::Widgets::TipoCursor cursor)
 
974
{
 
975
        if(m_cursor != cursor){
 
976
                for (GNC::GCS::ListaRenderers::iterator itr = m_Renderers.begin(); itr != m_Renderers.end(); itr++) {
 
977
                        switch (cursor){
 
978
                                case GNC::GCS::Widgets::CUR_TRANSPARENTE:
 
979
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorTransparente()));
 
980
                                        break;
 
981
                                case GNC::GCS::Widgets::CUR_LUPA:
 
982
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorLupa()));
 
983
                                        break;
 
984
                                case GNC::GCS::Widgets::CUR_SELECCION:
 
985
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorSeleccionar()));
 
986
                                        break;
 
987
                                case GNC::GCS::Widgets::CUR_FLECHA:
 
988
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(wxCURSOR_ARROW));
 
989
                                        break;
 
990
                                case GNC::GCS::Widgets::CUR_MANO_ABIERTA:
 
991
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorManoAbierta()));
 
992
                                        break;
 
993
                                case GNC::GCS::Widgets::CUR_MANO_CERRADA:
 
994
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorManoCerrada()));
 
995
                                        break;
 
996
                                case GNC::GCS::Widgets::CUR_CREAR_LINEA:
 
997
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorCrearLinea()));
 
998
                                        break;
 
999
                                case GNC::GCS::Widgets::CUR_CREAR_ANGULO_COBB:
 
1000
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorCrearAnguloCobb()));
 
1001
                                        break;
 
1002
                                case GNC::GCS::Widgets::CUR_CREAR_ANGULO_NORMAL:
 
1003
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorCrearAnguloNormal()));
 
1004
                                        break;
 
1005
                                case GNC::GCS::Widgets::CUR_CREAR_ANOTACION:
 
1006
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorCrearAnotacion()));
 
1007
                                        break;
 
1008
                                case GNC::GCS::Widgets::CUR_CREAR_ELIPSE:
 
1009
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorCrearElipse()));
 
1010
                                        break;
 
1011
                                case GNC::GCS::Widgets::CUR_CREAR_PUNTO:
 
1012
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorCrearPunto()));
 
1013
                                        break;
 
1014
                                case GNC::GCS::Widgets::CUR_CREAR_POLIGONO:
 
1015
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorCrearPoligono()));
 
1016
                                        break;
 
1017
                                case GNC::GCS::Widgets::CUR_CREAR_RECTANGULO:
 
1018
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorCrearRectangulo()));
 
1019
                                        break;
 
1020
                                case GNC::GCS::Widgets::CUR_WINDOW_LEVEL:
 
1021
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorWindowLevel()));
 
1022
                                        break;
 
1023
                                case GNC::GCS::Widgets::CUR_ANCLA_SIMPLE:
 
1024
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorAnclaSimple()));
 
1025
                                        break;
 
1026
                                case GNC::GCS::Widgets::CUR_ANCLA_COMPUESTA:
 
1027
                                        (*itr)->m_c->pWindow->SetCursor(wxCursor(GinkgoResourcesManager::Cursores::GetCursorAnclaCompuesta()));
 
1028
                                        break;
 
1029
                                case GNC::GCS::Widgets::CUR_INVALIDO:
 
1030
                                        break;
 
1031
                        }
 
1032
                }
 
1033
                m_cursor = cursor;
 
1034
        }
 
1035
}