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, as
6
* published by the Free Software Foundation; either version 2.1 or 3.0
9
* This program is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranties of
11
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12
* PURPOSE. See the applicable version of the GNU Lesser General Public
13
* License for more details.
15
* You should have received a copy of both the GNU Lesser General Public
16
* License along with this program. If not, see <http://www.gnu.org/licenses/>
18
* Authored by: Jay Taoko <jaytaoko@inalogic.com>
24
#include "PushButton.h"
30
PushButton::PushButton (const TCHAR *Caption, NUX_FILE_LINE_DECL)
31
: AbstractButton (Caption, NUX_FILE_LINE_PARAM)
36
mouse_click.connect (sigc::mem_fun (this, &PushButton::RecvClick) );
37
mouse_down.connect (sigc::mem_fun (this, &PushButton::RecvMouseDown) );
38
mouse_double_click.connect (sigc::mem_fun (this, &PushButton::RecvMouseDown) );
39
mouse_up.connect (sigc::mem_fun (this, &PushButton::RecvMouseUp) );
40
mouse_move.connect (sigc::mem_fun (this, &PushButton::RecvMouseMove) );
41
mouse_enter.connect (sigc::mem_fun (this, &PushButton::RecvMouseEnter) );
42
mouse_leave.connect (sigc::mem_fun (this, &PushButton::RecvMouseLeave) );
45
SetMinimumSize (DEFAULT_WIDGET_WIDTH, PRACTICAL_WIDGET_HEIGHT);
46
SetTextColor (color::Black);
51
PushButton::~PushButton()
55
long PushButton::ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
57
long ret = TraverseInfo;
58
ret = PostProcessEvent2 (ievent, ret, ProcessEventInfo);
62
void PushButton::Draw (GraphicsEngine &GfxContext, bool force_draw)
64
Geometry base = GetGeometry();
68
is.is_focus = IsMouseOwner();
70
is.is_prelight = IsMouseInside();
74
GetPainter().PushDrawSliceScaledTextureLayer (GfxContext, base, eBUTTON_FOCUS, color::White, eAllCorners);
75
GetPainter().PopBackground();
77
else if (is.is_prelight)
79
GetPainter().PushDrawSliceScaledTextureLayer (GfxContext, base, eBUTTON_PRELIGHT, color::White, eAllCorners);
80
GetPainter().PopBackground();
84
GetPainter().PushDrawSliceScaledTextureLayer (GfxContext, base, eBUTTON_NORMAL, color::White, eAllCorners);
85
GetPainter().PopBackground();
87
GetPainter().PaintTextLineStatic (GfxContext, GetFont (), base, GetBaseString().GetTCharPtr(), GetTextColor(), true, eAlignTextCenter);
90
void PushButton::DrawContent (GraphicsEngine &GfxContext, bool force_draw)
95
void PushButton::PostDraw (GraphicsEngine &GfxContext, bool force_draw)
100
void PushButton::SetCaption (const TCHAR *Caption)
102
if (Caption == 0 || (StringLength (Caption) == 0) )
104
SetBaseString (TEXT ("") );
107
SetBaseString (Caption);
110
const NString &PushButton::GetCaption() const
112
return GetBaseString();
115
void PushButton::SetState (bool b)
120
void PushButton::SetState (bool State, bool EmitSignal)
125
bool PushButton::GetState() const
130
void PushButton::RecvClick (int x, int y, unsigned long button_flags, unsigned long key_flags)
136
void PushButton::RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags)
141
void PushButton::RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags)
146
void PushButton::RecvMouseMove (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
151
void PushButton::RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)
156
void PushButton::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)