nux-1.14.0
VSeparator.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 
00025 #include "AbstractSeparator.h"
00026 #include "VSeparator.h"
00027 
00028 namespace nux
00029 {
00030 
00031   VSeparator::VSeparator()
00032 //:   AbstractSeparator(0xFF999999, 0.0f, 151.0f, 10)
00033   {
00034     InitializeWidgets();
00035     InitializeLayout();
00036   }
00037 
00038   VSeparator::VSeparator (const Color &color, float Alpha0, float Alpha1, int Border)
00039     :   AbstractSeparator (color, Alpha0, Alpha1, Border)
00040   {
00041     InitializeWidgets();
00042     InitializeLayout();
00043   }
00044 
00045   VSeparator::~VSeparator()
00046   {
00047 
00048   }
00049 
00050   void VSeparator::InitializeWidgets()
00051   {
00052     SetMinimumWidth (3);
00053     SetMaximumWidth (3);
00054   }
00055 
00056   void VSeparator::InitializeLayout()
00057   {
00058 
00059   }
00060 
00061   long VSeparator::ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
00062   {
00063     return TraverseInfo;
00064   }
00065 
00066   void VSeparator::Draw (GraphicsEngine &GfxContext, bool force_draw)
00067   {
00068     Geometry base = GetGeometry();
00069     int x0 = base.x + base.GetWidth() / 2;
00070     base.OffsetPosition (0, 3);
00071     base.OffsetSize (0, -6);
00072     GetGraphicsDisplay()->GetGraphicsEngine()->GetRenderStates().SetBlend (TRUE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00073 
00074     if (base.GetHeight() - 2 * m_BorderSize > 0)
00075     {
00076       // TODO: Tim Penhey 2011-05-13
00077       // This code is a copy of some other code somewhere... we should make sure there
00078       // is only one implementation.
00079       Color color0 = m_Color;
00080       Color color1 = m_Color;
00081       color0.alpha = m_Alpha0;
00082       color1.alpha = m_Alpha1;
00083       GetPainter().Draw2DLine (GfxContext, x0, base.y, x0, base.y + m_BorderSize, color0, color1);
00084       GetPainter().Draw2DLine (GfxContext, x0, base.y + m_BorderSize, x0, base.y + base.GetHeight() - m_BorderSize, color1, color1);
00085       GetPainter().Draw2DLine (GfxContext, x0, base.y + base.GetHeight() - m_BorderSize, x0, base.y + base.GetHeight(), color1, color0);
00086     }
00087     else
00088     {
00089       Color color1 = m_Color;
00090       color1.alpha = m_Alpha1;
00091       GetPainter().Draw2DLine (GfxContext, x0, base.y, x0, base.y + base.GetHeight(), color1);
00092     }
00093 
00094     GetGraphicsDisplay()->GetGraphicsEngine()->GetRenderStates().SetBlend (FALSE);
00095   }
00096 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends