~om26er/ubuntu/oneiric/nux/sru-888039

« back to all changes in this revision

Viewing changes to Nux/PushButton.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-08-11 18:29:22 UTC
  • mfrom: (1.1.25 upstream)
  • Revision ID: james.westby@ubuntu.com-20110811182922-lbfkhxvubg5z59pb
Tags: 1.2.0-0ubuntu1
* New upstream release.
* debian/rules:
  - bump shlib

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2010 Inalogic® Inc.
3
 
 *
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
7
 
 * of the License.
8
 
 *
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.
14
 
 *
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/>
17
 
 *
18
 
 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
19
 
 *
20
 
 */
21
 
 
22
 
 
23
 
#include "Nux.h"
24
 
#include "PushButton.h"
25
 
#include "HLayout.h"
26
 
 
27
 
namespace nux
28
 
{
29
 
 
30
 
  PushButton::PushButton (const TCHAR *Caption, NUX_FILE_LINE_DECL)
31
 
    :   AbstractButton (Caption, NUX_FILE_LINE_PARAM)
32
 
  {
33
 
    _state     = false;
34
 
 
35
 
    // Set Signals
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) );
43
 
 
44
 
    // Set Geometry
45
 
    SetMinimumSize (DEFAULT_WIDGET_WIDTH, PRACTICAL_WIDGET_HEIGHT);
46
 
    SetTextColor (color::Black);
47
 
 
48
 
    SetCaption (Caption);
49
 
  }
50
 
 
51
 
  PushButton::~PushButton()
52
 
  {
53
 
  }
54
 
 
55
 
  long PushButton::ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
56
 
  {
57
 
    long ret = TraverseInfo;
58
 
    ret = PostProcessEvent2 (ievent, ret, ProcessEventInfo);
59
 
    return ret;
60
 
  }
61
 
 
62
 
  void PushButton::Draw (GraphicsEngine &GfxContext, bool force_draw)
63
 
  {
64
 
    Geometry base = GetGeometry();
65
 
 
66
 
    InteractState is;
67
 
    is.is_on = _state;
68
 
    is.is_focus = IsMouseOwner();
69
 
 
70
 
    is.is_prelight = IsMouseInside();
71
 
 
72
 
    if (is.is_focus)
73
 
    {
74
 
      GetPainter().PushDrawSliceScaledTextureLayer (GfxContext, base, eBUTTON_FOCUS, color::White, eAllCorners);
75
 
      GetPainter().PopBackground();
76
 
    }
77
 
    else if (is.is_prelight)
78
 
    {
79
 
      GetPainter().PushDrawSliceScaledTextureLayer (GfxContext, base, eBUTTON_PRELIGHT, color::White, eAllCorners);
80
 
      GetPainter().PopBackground();
81
 
    }
82
 
    else
83
 
    {
84
 
      GetPainter().PushDrawSliceScaledTextureLayer (GfxContext, base, eBUTTON_NORMAL, color::White, eAllCorners);
85
 
      GetPainter().PopBackground();
86
 
    }
87
 
    GetPainter().PaintTextLineStatic (GfxContext, GetFont (), base, GetBaseString().GetTCharPtr(), GetTextColor(), true, eAlignTextCenter);
88
 
  }
89
 
 
90
 
  void PushButton::DrawContent (GraphicsEngine &GfxContext, bool force_draw)
91
 
  {
92
 
 
93
 
  }
94
 
 
95
 
  void PushButton::PostDraw (GraphicsEngine &GfxContext, bool force_draw)
96
 
  {
97
 
 
98
 
  }
99
 
 
100
 
  void PushButton::SetCaption (const TCHAR *Caption)
101
 
  {
102
 
    if (Caption == 0 || (StringLength (Caption) == 0) )
103
 
    {
104
 
      SetBaseString (TEXT ("") );
105
 
    }
106
 
    else
107
 
      SetBaseString (Caption);
108
 
  }
109
 
 
110
 
  const NString &PushButton::GetCaption() const
111
 
  {
112
 
    return GetBaseString();
113
 
  }
114
 
 
115
 
  void PushButton::SetState (bool b)
116
 
  {
117
 
 
118
 
  }
119
 
 
120
 
  void PushButton::SetState (bool State, bool EmitSignal)
121
 
  {
122
 
 
123
 
  }
124
 
 
125
 
  bool PushButton::GetState() const
126
 
  {
127
 
    return false;
128
 
  }
129
 
 
130
 
  void PushButton::RecvClick (int x, int y, unsigned long button_flags, unsigned long key_flags)
131
 
  {
132
 
    sigClick.emit();
133
 
    QueueDraw();
134
 
  }
135
 
 
136
 
  void PushButton::RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags)
137
 
  {
138
 
    QueueDraw();
139
 
  }
140
 
 
141
 
  void PushButton::RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags)
142
 
  {
143
 
    QueueDraw();
144
 
  }
145
 
 
146
 
  void PushButton::RecvMouseMove (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
147
 
  {
148
 
 
149
 
  }
150
 
 
151
 
  void PushButton::RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)
152
 
  {
153
 
    QueueDraw();
154
 
  }
155
 
 
156
 
  void PushButton::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)
157
 
  {
158
 
    QueueDraw();
159
 
  }
160
 
}