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

« back to all changes in this revision

Viewing changes to src/cadxcore/widgets/wnota.h

  • 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: wnota.h 3535 2011-03-18 17:57:05Z carlos $
 
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
#pragma once
 
15
#include <cmath>
 
16
#include <api/iwidgets.h>
 
17
#include <api/widgetserializable.h>
 
18
#include <widgets/openglhelper.h>
 
19
 
 
20
//----------------------------------------------------------------------------------------------------
 
21
//region Forward Declarations
 
22
namespace GNC {
 
23
        namespace GCS {
 
24
                namespace Widgets {
 
25
                        
 
26
                        namespace Dialogos {
 
27
                                class SeleccionTexto;
 
28
                        }
 
29
                        
 
30
                        class WCajaTexto;
 
31
                }
 
32
        }
 
33
}
 
34
//endregion
 
35
 
 
36
namespace GNC {
 
37
        namespace GCS {
 
38
                namespace Widgets {
 
39
 
 
40
                        namespace Dialogos {
 
41
                                class SeleccionTexto;
 
42
                        }
 
43
 
 
44
                        class WCajaTexto;
 
45
 
 
46
                        //====================================================================================================
 
47
                        //= Builder de notas
 
48
                        //====================================================================================================
 
49
                        class WNotaBuilder : public GNC::GCS::Widgets::IWidgetBuilder {
 
50
                        public:
 
51
                                typedef GNC::GCS::Vector TVector;
 
52
                                WNotaBuilder(GNC::GCS::IWidgetsManager* pManager);
 
53
 
 
54
                                ~WNotaBuilder();
 
55
 
 
56
                                virtual void OnMouseEvents(GNC::GCS::Eventos::EventoRaton&);
 
57
 
 
58
                                virtual void OnKeyEvents(GNC::GCS::Eventos::EventoTeclado&);
 
59
 
 
60
                                virtual void Render(GNC::GCS::Contexto3D* c);
 
61
 
 
62
                                virtual GNC::GCS::Widgets::TipoCursor GetCursor();
 
63
 
 
64
                        protected:
 
65
                                TVector m_Posicion;
 
66
                                GNC::GCS::Widgets::IWidgetBuilder::Estado m_Estado;
 
67
                                bool m_MouseDown;
 
68
 
 
69
                                WCajaTexto* m_pTempWidget;
 
70
 
 
71
                        };
 
72
 
 
73
                        //====================================================================================================
 
74
                        //= Widget de notas
 
75
                        //====================================================================================================
 
76
                        class WCajaTexto : public GNC::GCS::Widgets::IWidget, public GNC::GCS::Widgets::IWidgetSerializable {
 
77
 
 
78
                        public:
 
79
                                typedef GNC::GCS::Vector TVector;
 
80
                                typedef GNC::GCS::Matriz TMatriz;
 
81
 
 
82
                                WCajaTexto(IWidgetsManager* pManager, long vid, TVector posicion, const char* nombre = "", std::string texto = "");
 
83
 
 
84
                                ~WCajaTexto();
 
85
                                
 
86
                        //----------------------------------------------------------------------------------------------------
 
87
                        //region "Serializado y desserializado"
 
88
                        public:
 
89
                                WCajaTexto(IWidgetsManager* pManager, long vid, wxXmlNode* nodo);
 
90
 
 
91
                                wxXmlNode* Serializar(const std::string& nombreMedico);
 
92
                        //endregion
 
93
 
 
94
                                TVector          m_Posicion;
 
95
                                TVector          m_PosAntigua;
 
96
 
 
97
                                TVector          m_Quad[4];
 
98
 
 
99
                                GNC::GCS::Vector m_TamTexto;
 
100
 
 
101
                                std::string      m_Texto;
 
102
                                bool             m_Vacio;
 
103
 
 
104
                                Color            m_Color;
 
105
 
 
106
                                typedef struct TexturaNota {
 
107
                                        std::string texto;
 
108
                                        TexturaCairo* m_textura;
 
109
                                        bool    correcta;       //indica si esta correctamente cargada
 
110
                                        TexturaNota()
 
111
                                        {
 
112
                                                m_textura = new GNC::GCS::TexturaCairo();
 
113
                                                m_textura->ActivarInterpolacion();
 
114
                                                texto = "";
 
115
                                                correcta = false;
 
116
                                        }
 
117
                                        ~TexturaNota()
 
118
                                        {
 
119
                                                m_textura->Descargar();
 
120
                                                delete m_textura;
 
121
                                        }
 
122
                                } TexturaNota;
 
123
                                typedef std::map<void*,TexturaNota*> TMapaRecursos;
 
124
                                TMapaRecursos m_mapaRecursos;
 
125
                                TexturaNota* GetTextura(void* renderer);
 
126
                                void Invalidar();
 
127
 
 
128
                                GNC::GCS::Widgets::Dialogos::SeleccionTexto* m_pWidgetSeleccion;
 
129
 
 
130
                        protected:
 
131
                                bool m_MouseDown;
 
132
 
 
133
                                float m_AnchoMaximo;
 
134
                                float m_TamFuente;
 
135
                        
 
136
 
 
137
                        //----------------------------------------------------------------------------------------------------
 
138
                        //region "Colores"
 
139
                        public:
 
140
 
 
141
                                virtual void SetColor(Color color);
 
142
                                virtual const std::string& GetTexto() const;
 
143
                                virtual void SetTexto(const std::string& texto);
 
144
                                virtual void PropagarModificacion();
 
145
                                virtual const Color& GetColor() const;
 
146
                        //endregion
 
147
                                
 
148
                        //----------------------------------------------------------------------------------------------------
 
149
                        //region "Interfaz especifica"
 
150
                        public:
 
151
 
 
152
                                virtual bool SoportaAutoBorrado() const {
 
153
                                        return true;
 
154
                                }
 
155
 
 
156
                                virtual void OnMouseEvents(GNC::GCS::Eventos::EventoRaton&);
 
157
 
 
158
                                virtual void OnKeyEvents(GNC::GCS::Eventos::EventoTeclado&);
 
159
 
 
160
                                virtual bool HitTest(float x, float y, float umbralCuadrado);
 
161
 
 
162
                                virtual bool HitTest(GNC::GCS::Vector* vertices, int numVertices);
 
163
 
 
164
                                virtual void Render(GNC::GCS::Contexto3D* c);
 
165
                                
 
166
                                virtual void OffscreenRender(Contexto3D* c);
 
167
 
 
168
                                virtual void Seleccionar(bool seleccionado);
 
169
 
 
170
                                virtual void Iluminar(bool iluminado);
 
171
 
 
172
                                virtual void Ocultar(bool oculto);
 
173
                                
 
174
                                virtual void LiberarRecursos(GNC::GCS::IWidgetsRenderer* pKey);
 
175
 
 
176
                        //----------------------------------------------------------------------------------------------------
 
177
                        //region "Helpers"
 
178
                        public:
 
179
                                virtual void Recalcular(void* renderer);
 
180
                        //endregion
 
181
 
 
182
                        //----------------------------------------------------------------------------------------------------
 
183
                        //region "Menu contextual"
 
184
                        public:
 
185
                                virtual bool GetMenuContextual(wxMenu* , wxWindow* pParent) ;
 
186
                        //endregion
 
187
                                
 
188
                                
 
189
                                virtual void InsertarPropiedades(TListaMapasPropiedades &listaMapaPropiedades);
 
190
 
 
191
                        };
 
192
                }
 
193
        }
 
194
}