2
* Copyright 2010 Inalogic Inc.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3, as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the applicable version of the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of both the GNU Lesser General Public
15
* License version 3 along with this program. If not, see
16
* <http://www.gnu.org/licenses/>
18
* Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
24
#include "AbstractComboBox.h"
30
Color AbstractComboBox::m_sCOMBO_COLOR = Color (0xFF9F9F9F);
31
Color AbstractComboBox::m_sCOMBO_BUTTON_COLOR = Color (0xFF4D4D4D);
32
Color AbstractComboBox::m_sCOMBO_MOUSEOVER_COLOR = Color (0xFF222222);
34
AbstractComboBox::AbstractComboBox (NUX_FILE_LINE_DECL)
35
: View (NUX_FILE_LINE_PARAM)
36
, m_MenuIsActive (false)
42
AbstractComboBox::~AbstractComboBox()
47
void AbstractComboBox::InitializeWidgets()
49
m_hlayout->AddView (m_ComboArea, 1);
50
m_hlayout->AddView (m_Button, 0);
51
m_hlayout->SetHorizontalExternalMargin (0);
52
m_hlayout->SetVerticalExternalMargin (0);
53
SetCompositionLayout (m_hlayout);
55
m_ComboArea->OnMouseEnter.connect (sigc::mem_fun (this, &AbstractComboBox::RecvMouseEnter) );
56
m_ComboArea->OnMouseLeave.connect (sigc::mem_fun (this, &AbstractComboBox::RecvMouseLeave) );
58
m_Button->OnMouseEnter.connect (sigc::mem_fun (this, &AbstractComboBox::RecvMouseEnter) );
59
m_Button->OnMouseLeave.connect (sigc::mem_fun (this, &AbstractComboBox::RecvMouseLeave) );
61
SetTextColor (Color::Black);
64
void AbstractComboBox::InitializeLayout()
66
m_hlayout = new HLayout();
67
m_ComboArea = new CoreArea();
68
m_Button = new CoreArea();
71
void AbstractComboBox::DestroyLayout()
75
void AbstractComboBox::Draw (GraphicsEngine &GfxContext, bool force_draw)
77
Geometry base = GetGeometry();
78
GetPainter().PaintBackground (GfxContext, base);
79
GetPainter().PaintShape (GfxContext, base, m_sCOMBO_COLOR, eSHAPE_CORNER_ROUND4);
80
GetPainter().PaintTextLineStatic (GfxContext, GetFont(), m_ComboArea->GetGeometry(), m_ComboArea->GetBaseString().GetTCharPtr(), GetTextColor(), eAlignTextLeft);
81
Geometry button_geo = m_Button->GetGeometry();
82
button_geo.OffsetSize (-5, -2);
83
button_geo.OffsetPosition (+4, +1);
85
if (m_ComboArea->IsMouseInside() || m_Button->IsMouseInside() )
86
GetPainter().PaintShape (GfxContext, button_geo, m_sCOMBO_MOUSEOVER_COLOR, eSHAPE_CORNER_ROUND4);
88
GetPainter().PaintShape (GfxContext, button_geo, m_sCOMBO_BUTTON_COLOR, eSHAPE_CORNER_ROUND4);
90
GeometryPositioning gp (eHACenter, eVACenter);
91
Geometry GeoPo = ComputeGeometryPositioning (button_geo, GetTheme().GetImageGeometry (eCOMBOBOX_OPEN_BUTTON), gp);
92
GetPainter().PaintShape (GfxContext, GeoPo, Color (0xFFFFFFFF), eCOMBOBOX_OPEN_BUTTON);
94
Geometry popup_geometry;
95
popup_geometry.SetX (m_ComboArea->GetBaseX() );
96
popup_geometry.SetY (m_ComboArea->GetBaseY() + m_ComboArea->GetBaseHeight() );
97
popup_geometry.SetWidth (m_ComboArea->GetBaseWidth() );
98
popup_geometry.SetHeight (m_ComboArea->GetBaseHeight() );
101
void AbstractComboBox::DrawContent (GraphicsEngine &GfxContext, bool force_draw)
103
GfxContext.PushClippingRectangle (GetGeometry() );
105
GfxContext.PopClippingRectangle();
108
void AbstractComboBox::PostDraw (GraphicsEngine &GfxContext, bool force_draw)
113
void AbstractComboBox::RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)
118
void AbstractComboBox::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)