nux-1.14.0
|
00001 /* 00002 * Copyright 2010 Inalogic® Inc. 00003 * 00004 * This program is free software: you can redistribute it and/or modify it 00005 * under the terms of the GNU Lesser General Public License, as 00006 * published by the Free Software Foundation; either version 2.1 or 3.0 00007 * of the License. 00008 * 00009 * This program is distributed in the hope that it will be useful, but 00010 * WITHOUT ANY WARRANTY; without even the implied warranties of 00011 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 00012 * PURPOSE. See the applicable version of the GNU Lesser General Public 00013 * License for more details. 00014 * 00015 * You should have received a copy of both the GNU Lesser General Public 00016 * License along with this program. If not, see <http://www.gnu.org/licenses/> 00017 * 00018 * Authored by: Jay Taoko <jaytaoko@inalogic.com> 00019 * 00020 */ 00021 00022 #include "Nux.h" 00023 #include "Matrix4Preview.h" 00024 #include "StaticTextBox.h" 00025 00026 namespace nux 00027 { 00028 00029 static const int GRAPH_MARGIN = 1; 00030 00031 Matrix4Preview::Matrix4Preview (Matrix4 matrix, NUX_FILE_LINE_DECL) 00032 : View (NUX_FILE_LINE_PARAM) 00033 { 00034 m_DialogThreadProxy = new Matrix4DialogProxy (true); 00035 00036 SetMinMaxSize (30, 30); 00037 00038 mouse_click.connect (sigc::mem_fun (this, &Matrix4Preview::RecvClick) ); 00039 00040 m_ChangeDetectionTimer = new TimerFunctor(); 00041 m_ChangeDetectionTimer->OnTimerExpired.connect (sigc::mem_fun (this, &Matrix4Preview::RecvTimer) ); 00042 m_ChangeTimerHandler = 0; 00043 } 00044 00045 Matrix4Preview::~Matrix4Preview() 00046 { 00047 delete m_ChangeDetectionTimer; 00048 00049 if (m_ChangeTimerHandler.IsValid() ) 00050 GetTimer().RemoveTimerHandler (m_ChangeTimerHandler); 00051 00052 NUX_SAFE_DELETE (m_DialogThreadProxy); 00053 } 00054 00055 long Matrix4Preview::ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo) 00056 { 00057 long ret = TraverseInfo; 00058 ret = PostProcessEvent2 (ievent, ret, ProcessEventInfo); 00059 return ret; 00060 } 00061 00062 void Matrix4Preview::Draw (GraphicsEngine &GfxContext, bool force_draw) 00063 { 00064 Geometry base = GetGeometry(); 00065 00066 GetPainter().PaintBackground (GfxContext, base); 00067 //GetPainter().PaintShape(GfxContext, base, 0xFF4D4D4D, eSHAPE_CORNER_ROUND4, false); 00068 00069 GeometryPositioning gp (eHACenter, eVACenter); 00070 Geometry GeoPo = ComputeGeometryPositioning (base, GetTheme().GetImageGeometry (eMATRIX4PREVIEW), gp); 00071 GetPainter().PaintShape (GfxContext, GeoPo, Color (0xFFFFFFFF), eMATRIX4PREVIEW); 00072 00073 GetPainter().Paint2DQuadWireframe (GfxContext, base, Color (COLOR_BACKGROUND_SECONDARY) ); 00074 00075 //GetPainter().Paint2DQuadWireframe(GfxContext, base, Color(COLOR_BACKGROUND_SECONDARY)); 00076 } 00077 00078 void Matrix4Preview::DrawContent (GraphicsEngine &GfxContext, bool force_draw) 00079 { 00080 } 00081 00082 void Matrix4Preview::PostDraw (GraphicsEngine &GfxContext, bool force_draw) 00083 { 00084 00085 } 00086 00087 void Matrix4Preview::RecvClick (int x, int y, unsigned long button_flags, unsigned long key_flags) 00088 { 00089 m_DialogThreadProxy->Start(); 00090 } 00091 00092 void Matrix4Preview::RecvTimer (void *v) 00093 { 00094 if (m_DialogThreadProxy->m_bDialogChange && m_DialogThreadProxy->m_bDialogRunning) 00095 { 00096 m_DialogThreadProxy->m_bDialogChange = false; 00097 m_Matrix = m_DialogThreadProxy->GetMatrix(); 00098 } 00099 00100 if (m_DialogThreadProxy->IsActive() ) 00101 { 00102 m_ChangeTimerHandler = GetTimer().AddTimerHandler (33, m_ChangeDetectionTimer, this); 00103 } 00104 else 00105 { 00106 if (m_ChangeTimerHandler.IsValid() ) 00107 GetTimer().RemoveTimerHandler (m_ChangeTimerHandler); 00108 00109 m_ChangeTimerHandler = 0; 00110 00111 m_Matrix = m_DialogThreadProxy->GetMatrix(); 00112 } 00113 } 00114 00115 void Matrix4Preview::RecvDialogChange (Matrix4Editor *matrixeditor) 00116 { 00117 } 00118 00119 void Matrix4Preview::SetMatrix (Matrix4 matrix) 00120 { 00121 m_Matrix = matrix; 00122 } 00123 00124 Matrix4 Matrix4Preview::GetMatrix() const 00125 { 00126 return m_Matrix; 00127 } 00128 00129 00130 }