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