nux-1.16.0
Matrix3Preview.cpp
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 
00023 #include "Nux.h"
00024 #include "Theme.h"
00025 #include "Matrix3Preview.h"
00026 #include "StaticTextBox.h"
00027 
00028 namespace nux
00029 {
00030 
00031   static const int GRAPH_MARGIN = 1;
00032 
00033   Matrix3Preview::Matrix3Preview (Matrix3 matrix, NUX_FILE_LINE_DECL)
00034     :   View (NUX_FILE_LINE_PARAM)
00035   {
00036     m_DialogThreadProxy = new Matrix3DialogProxy (true);
00037 
00038     SetMinMaxSize (30, 30);
00039 
00040     mouse_click.connect (sigc::mem_fun (this, &Matrix3Preview::RecvClick) );
00041 
00042     m_ChangeDetectionTimer = new TimerFunctor();
00043     m_ChangeDetectionTimer->OnTimerExpired.connect (sigc::mem_fun (this, &Matrix3Preview::RecvTimer) );
00044     m_ChangeTimerHandler = 0;
00045   }
00046 
00047   Matrix3Preview::~Matrix3Preview()
00048   {
00049     delete m_ChangeDetectionTimer;
00050 
00051     if (m_ChangeTimerHandler.IsValid() )
00052       GetTimer().RemoveTimerHandler (m_ChangeTimerHandler);
00053 
00054     NUX_SAFE_DELETE (m_DialogThreadProxy);
00055   }
00056 
00057   long Matrix3Preview::ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
00058   {
00059     long ret = TraverseInfo;
00060     ret = PostProcessEvent2 (ievent, ret, ProcessEventInfo);
00061     return ret;
00062   }
00063 
00064   void Matrix3Preview::Draw (GraphicsEngine &GfxContext, bool force_draw)
00065   {
00066     Geometry base = GetGeometry();
00067 
00068     GetPainter().PaintBackground (GfxContext, base);
00069     //GetPainter().PaintShape(GfxContext, base, 0xFF4D4D4D, eSHAPE_CORNER_ROUND4, false);
00070 
00071     GeometryPositioning gp (eHACenter, eVACenter);
00072     Geometry GeoPo = ComputeGeometryPositioning (base, GetTheme().GetImageGeometry (eMATRIX3PREVIEW), gp);
00073     GetPainter().PaintShape (GfxContext, GeoPo, Color (0xFFFFFFFF), eMATRIX3PREVIEW);
00074 
00075     GetPainter().Paint2DQuadWireframe (GfxContext, base, Color (COLOR_BACKGROUND_SECONDARY) );
00076     //GetPainter().Paint2DQuadWireframe(GfxContext, base, Color(COLOR_BACKGROUND_SECONDARY));
00077   }
00078 
00079   void Matrix3Preview::DrawContent (GraphicsEngine &GfxContext, bool force_draw)
00080   {
00081   }
00082 
00083   void Matrix3Preview::PostDraw (GraphicsEngine &GfxContext, bool force_draw)
00084   {
00085 
00086   }
00087 
00088   void Matrix3Preview::RecvClick (int x, int y, unsigned long button_flags, unsigned long key_flags)
00089   {
00090     m_DialogThreadProxy->Start();
00091 
00092     m_ChangeTimerHandler = GetTimer().AddTimerHandler (33, m_ChangeDetectionTimer, this);
00093   }
00094 
00095   void Matrix3Preview::RecvTimer (void *v)
00096   {
00097     if (m_DialogThreadProxy->m_bDialogChange && m_DialogThreadProxy->m_bDialogRunning)
00098     {
00099       m_DialogThreadProxy->m_bDialogChange = false;
00100       m_Matrix = m_DialogThreadProxy->GetMatrix();
00101     }
00102 
00103     if (m_DialogThreadProxy->IsActive() )
00104     {
00105       m_ChangeTimerHandler = GetTimer().AddTimerHandler (33, m_ChangeDetectionTimer, this);
00106     }
00107     else
00108     {
00109       if (m_ChangeTimerHandler.IsValid() )
00110         GetTimer().RemoveTimerHandler (m_ChangeTimerHandler);
00111 
00112       m_ChangeTimerHandler = 0;
00113 
00114       m_Matrix = m_DialogThreadProxy->GetMatrix();
00115     }
00116   }
00117 
00118   void Matrix3Preview::RecvDialogChange (Matrix3Editor *matrixeditor)
00119   {
00120   }
00121 
00122   void Matrix3Preview::SetMatrix (Matrix3 matrix)
00123   {
00124     m_Matrix = matrix;
00125   }
00126 
00127   Matrix3 Matrix3Preview::GetMatrix() const
00128   {
00129     return m_Matrix;
00130   }
00131 
00132 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends