~ubuntu-branches/ubuntu/oneiric/nux/oneiric

« back to all changes in this revision

Viewing changes to Nux/SpinBox_Logic.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-12-09 19:56:53 UTC
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20101209195653-lsc4objqdxs9exp3
Tags: upstream-0.9.10
ImportĀ upstreamĀ versionĀ 0.9.10

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 version 3, as
6
 
 * published by the  Free Software Foundation.
7
 
 *
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.
13
 
 *
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/>
17
 
 *
18
 
 * Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
19
 
 *
20
 
 */
21
 
 
22
 
 
23
 
#include "Nux.h"
24
 
#include "TimerProc.h"
25
 
#include "SpinBox_Logic.h"
26
 
 
27
 
namespace nux
28
 
{
29
 
 
30
 
  SpinBox_Logic::SpinBox_Logic (NUX_FILE_LINE_DECL)
31
 
    :   View (NUX_FILE_LINE_PARAM)
32
 
    ,   m_UpTimerHandler (0)
33
 
    ,   m_DownTimerHandler (0)
34
 
  {
35
 
    InitializeLayout();
36
 
    InitializeWidgets();
37
 
  }
38
 
 
39
 
  SpinBox_Logic::~SpinBox_Logic()
40
 
  {
41
 
    DestroyLayout();
42
 
  }
43
 
 
44
 
  void SpinBox_Logic::InitializeWidgets()
45
 
  {
46
 
    // Set Original State
47
 
    m_EditLine->SetSuffix (TEXT ("") );
48
 
    m_EditLine->SetPrefix (TEXT ("") );
49
 
 
50
 
    // Set Signals
51
 
    m_SpinnerUpBtn->OnMouseDown.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvIncrement) );
52
 
    m_SpinnerUpBtn->OnMouseDoubleClick.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvIncrement) );
53
 
    m_SpinnerUpBtn->OnMouseUp.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvSpinnerMouseUp) );
54
 
    m_SpinnerUpBtn->OnMouseClick.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvSpinnerMouseUp) );
55
 
    m_SpinnerUpBtn->OnMouseEnter.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseEnter) );
56
 
    m_SpinnerUpBtn->OnMouseLeave.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseLeave) );
57
 
 
58
 
    m_SpinnerDownBtn->OnMouseDown.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvDecrement) );
59
 
    m_SpinnerDownBtn->OnMouseDoubleClick.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvDecrement) );
60
 
    m_SpinnerDownBtn->OnMouseUp.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvSpinnerMouseUp) );
61
 
    m_SpinnerDownBtn->OnMouseClick.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvSpinnerMouseUp) );
62
 
    m_SpinnerDownBtn->OnMouseEnter.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseEnter) );
63
 
    m_SpinnerDownBtn->OnMouseLeave.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseLeave) );
64
 
 
65
 
    m_EditLine->sigValidateEntry.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvValidateEntry) );
66
 
    m_EditLine->sigStartKeyboardFocus.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvStartKeyboardFocus) );
67
 
    m_EditLine->sigEndKeyboardFocus.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvEndKeyboardFocus) );
68
 
    m_EditLine->sigEscapeKeyboardFocus.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvEscapeKeyboardFocus) );
69
 
    m_EditLine->sigEditChange.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvEditChange) );
70
 
    m_EditLine->OnMouseEnter.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseEnter) );
71
 
    m_EditLine->OnMouseLeave.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseLeave) );
72
 
 
73
 
    m_UpTimerCallback = new TimerFunctor;
74
 
    m_UpTimerCallback->OnTimerExpired.connect (sigc::mem_fun (this, &SpinBox_Logic::TimerSpinUpBtn) );
75
 
    m_DownTimerCallback = new TimerFunctor;
76
 
    m_DownTimerCallback->OnTimerExpired.connect (sigc::mem_fun (this, &SpinBox_Logic::TimerSpinDownBtn) );
77
 
  }
78
 
 
79
 
  void SpinBox_Logic::InitializeLayout()
80
 
  {
81
 
    m_SpinnerUpBtn      = new CoreArea (NUX_TRACKER_LOCATION);
82
 
    m_SpinnerDownBtn    = new CoreArea (NUX_TRACKER_LOCATION);
83
 
    m_EditLine          = new EditTextBox (TEXT (""), NUX_TRACKER_LOCATION);
84
 
  }
85
 
 
86
 
  void SpinBox_Logic::DestroyLayout()
87
 
  {
88
 
  }
89
 
 
90
 
  void SpinBox_Logic::RecvIncrement (int x, int y, unsigned long button_flags, unsigned long key_flags)
91
 
  {
92
 
    TimerSpinUpBtn (0);
93
 
  }
94
 
 
95
 
  void SpinBox_Logic::RecvSpinnerMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags)
96
 
  {
97
 
    if (m_UpTimerHandler.IsValid() )
98
 
    {
99
 
      GetTimer().RemoveTimerHandler (m_UpTimerHandler);
100
 
      m_UpTimerHandler = 0;
101
 
    }
102
 
 
103
 
    if (m_DownTimerHandler.IsValid() )
104
 
    {
105
 
      GetTimer().RemoveTimerHandler (m_DownTimerHandler);
106
 
      m_DownTimerHandler = 0;
107
 
    }
108
 
 
109
 
    NeedRedraw();
110
 
  }
111
 
 
112
 
  void SpinBox_Logic::RecvDecrement (int x, int y, unsigned long button_flags, unsigned long key_flags)
113
 
  {
114
 
    TimerSpinDownBtn (0);
115
 
  }
116
 
 
117
 
  void SpinBox_Logic::TimerSpinUpBtn (void *v)
118
 
  {
119
 
    ImplementIncrementBtn();
120
 
  }
121
 
 
122
 
  void SpinBox_Logic::TimerSpinDownBtn (void *v)
123
 
  {
124
 
    ImplementDecrementBtn();
125
 
  }
126
 
 
127
 
  void SpinBox_Logic::RecvStartKeyboardFocus (EditTextBox *textbox)
128
 
  {
129
 
    NeedRedraw();
130
 
  }
131
 
 
132
 
  void SpinBox_Logic::RecvEndKeyboardFocus (EditTextBox *textbox)
133
 
  {
134
 
    NeedRedraw();
135
 
  }
136
 
 
137
 
  void SpinBox_Logic::RecvEscapeKeyboardFocus (EditTextBox *textbox)
138
 
  {
139
 
    NeedRedraw();
140
 
  }
141
 
 
142
 
  void SpinBox_Logic::RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)
143
 
  {
144
 
    NeedRedraw();
145
 
  }
146
 
 
147
 
  void SpinBox_Logic::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)
148
 
  {
149
 
    NeedRedraw();
150
 
  }
151
 
 
152
 
  void SpinBox_Logic::RecvMouseMove (int x, int y, unsigned long button_flags, unsigned long key_flags)
153
 
  {
154
 
    NeedRedraw();
155
 
  }
156
 
 
157
 
  void SpinBox_Logic::RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
158
 
  {
159
 
    NeedRedraw();
160
 
  }
161
 
 
162
 
  void SpinBox_Logic::RecvEditChange (EditTextBox *textbox)
163
 
  {
164
 
    NeedRedraw();
165
 
  }
166
 
 
167
 
  void SpinBox_Logic::RecvValidateEntry (EditTextBox *textbox)
168
 
  {
169
 
    ImplementValidateEntry();
170
 
 
171
 
//    int ret = 0;
172
 
//    if(inlCharToInteger(m_EditLine->GetCleanCaption().GetTChar(), ret))
173
 
//    {
174
 
//        m_iValue = ret;
175
 
//        if(m_iValue < m_IntValidator.GetMinimum())
176
 
//        {
177
 
//            m_iValue = m_IntValidator.GetMinimum();
178
 
//            m_EditLine->setCaption(inlPrintf("%d", m_iValue));
179
 
//        }
180
 
//        if(m_iValue > m_IntValidator.GetMaximum())
181
 
//        {
182
 
//            m_iValue = m_IntValidator.GetMaximum();
183
 
//            m_EditLine->setCaption(inlPrintf("%d", m_iValue));
184
 
//        }
185
 
//    }
186
 
//    else
187
 
//    {
188
 
//        m_EditLine->setCaption(inlPrintf("%d", m_iValue));
189
 
//    }
190
 
  }
191
 
 
192
 
}
 
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 version 3, as
 
6
 * published by the  Free Software Foundation.
 
7
 *
 
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.
 
13
 *
 
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/>
 
17
 *
 
18
 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
 
19
 *
 
20
 */
 
21
 
 
22
 
 
23
#include "Nux.h"
 
24
#include "TimerProc.h"
 
25
#include "SpinBox_Logic.h"
 
26
 
 
27
namespace nux
 
28
{
 
29
 
 
30
  SpinBox_Logic::SpinBox_Logic (NUX_FILE_LINE_DECL)
 
31
    :   View (NUX_FILE_LINE_PARAM)
 
32
    ,   m_UpTimerHandler (0)
 
33
    ,   m_DownTimerHandler (0)
 
34
  {
 
35
    InitializeLayout();
 
36
    InitializeWidgets();
 
37
  }
 
38
 
 
39
  SpinBox_Logic::~SpinBox_Logic()
 
40
  {
 
41
    DestroyLayout();
 
42
  }
 
43
 
 
44
  void SpinBox_Logic::InitializeWidgets()
 
45
  {
 
46
    // Set Original State
 
47
    m_EditLine->SetSuffix (TEXT ("") );
 
48
    m_EditLine->SetPrefix (TEXT ("") );
 
49
 
 
50
    // Set Signals
 
51
    m_SpinnerUpBtn->OnMouseDown.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvIncrement) );
 
52
    m_SpinnerUpBtn->OnMouseDoubleClick.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvIncrement) );
 
53
    m_SpinnerUpBtn->OnMouseUp.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvSpinnerMouseUp) );
 
54
    m_SpinnerUpBtn->OnMouseClick.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvSpinnerMouseUp) );
 
55
    m_SpinnerUpBtn->OnMouseEnter.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseEnter) );
 
56
    m_SpinnerUpBtn->OnMouseLeave.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseLeave) );
 
57
 
 
58
    m_SpinnerDownBtn->OnMouseDown.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvDecrement) );
 
59
    m_SpinnerDownBtn->OnMouseDoubleClick.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvDecrement) );
 
60
    m_SpinnerDownBtn->OnMouseUp.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvSpinnerMouseUp) );
 
61
    m_SpinnerDownBtn->OnMouseClick.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvSpinnerMouseUp) );
 
62
    m_SpinnerDownBtn->OnMouseEnter.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseEnter) );
 
63
    m_SpinnerDownBtn->OnMouseLeave.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseLeave) );
 
64
 
 
65
    m_EditLine->sigValidateEntry.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvValidateEntry) );
 
66
    m_EditLine->sigStartKeyboardFocus.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvStartKeyboardFocus) );
 
67
    m_EditLine->sigEndKeyboardFocus.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvEndKeyboardFocus) );
 
68
    m_EditLine->sigEscapeKeyboardFocus.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvEscapeKeyboardFocus) );
 
69
    m_EditLine->sigEditChange.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvEditChange) );
 
70
    m_EditLine->OnMouseEnter.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseEnter) );
 
71
    m_EditLine->OnMouseLeave.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseLeave) );
 
72
 
 
73
    m_UpTimerCallback = new TimerFunctor;
 
74
    m_UpTimerCallback->OnTimerExpired.connect (sigc::mem_fun (this, &SpinBox_Logic::TimerSpinUpBtn) );
 
75
    m_DownTimerCallback = new TimerFunctor;
 
76
    m_DownTimerCallback->OnTimerExpired.connect (sigc::mem_fun (this, &SpinBox_Logic::TimerSpinDownBtn) );
 
77
  }
 
78
 
 
79
  void SpinBox_Logic::InitializeLayout()
 
80
  {
 
81
    m_SpinnerUpBtn      = new CoreArea (NUX_TRACKER_LOCATION);
 
82
    m_SpinnerDownBtn    = new CoreArea (NUX_TRACKER_LOCATION);
 
83
    m_EditLine          = new EditTextBox (TEXT (""), NUX_TRACKER_LOCATION);
 
84
  }
 
85
 
 
86
  void SpinBox_Logic::DestroyLayout()
 
87
  {
 
88
  }
 
89
 
 
90
  void SpinBox_Logic::RecvIncrement (int x, int y, unsigned long button_flags, unsigned long key_flags)
 
91
  {
 
92
    TimerSpinUpBtn (0);
 
93
  }
 
94
 
 
95
  void SpinBox_Logic::RecvSpinnerMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags)
 
96
  {
 
97
    if (m_UpTimerHandler.IsValid() )
 
98
    {
 
99
      GetTimer().RemoveTimerHandler (m_UpTimerHandler);
 
100
      m_UpTimerHandler = 0;
 
101
    }
 
102
 
 
103
    if (m_DownTimerHandler.IsValid() )
 
104
    {
 
105
      GetTimer().RemoveTimerHandler (m_DownTimerHandler);
 
106
      m_DownTimerHandler = 0;
 
107
    }
 
108
 
 
109
    NeedRedraw();
 
110
  }
 
111
 
 
112
  void SpinBox_Logic::RecvDecrement (int x, int y, unsigned long button_flags, unsigned long key_flags)
 
113
  {
 
114
    TimerSpinDownBtn (0);
 
115
  }
 
116
 
 
117
  void SpinBox_Logic::TimerSpinUpBtn (void *v)
 
118
  {
 
119
    ImplementIncrementBtn();
 
120
  }
 
121
 
 
122
  void SpinBox_Logic::TimerSpinDownBtn (void *v)
 
123
  {
 
124
    ImplementDecrementBtn();
 
125
  }
 
126
 
 
127
  void SpinBox_Logic::RecvStartKeyboardFocus (EditTextBox *textbox)
 
128
  {
 
129
    NeedRedraw();
 
130
  }
 
131
 
 
132
  void SpinBox_Logic::RecvEndKeyboardFocus (EditTextBox *textbox)
 
133
  {
 
134
    NeedRedraw();
 
135
  }
 
136
 
 
137
  void SpinBox_Logic::RecvEscapeKeyboardFocus (EditTextBox *textbox)
 
138
  {
 
139
    NeedRedraw();
 
140
  }
 
141
 
 
142
  void SpinBox_Logic::RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)
 
143
  {
 
144
    NeedRedraw();
 
145
  }
 
146
 
 
147
  void SpinBox_Logic::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)
 
148
  {
 
149
    NeedRedraw();
 
150
  }
 
151
 
 
152
  void SpinBox_Logic::RecvMouseMove (int x, int y, unsigned long button_flags, unsigned long key_flags)
 
153
  {
 
154
    NeedRedraw();
 
155
  }
 
156
 
 
157
  void SpinBox_Logic::RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
 
158
  {
 
159
    NeedRedraw();
 
160
  }
 
161
 
 
162
  void SpinBox_Logic::RecvEditChange (EditTextBox *textbox)
 
163
  {
 
164
    NeedRedraw();
 
165
  }
 
166
 
 
167
  void SpinBox_Logic::RecvValidateEntry (EditTextBox *textbox)
 
168
  {
 
169
    ImplementValidateEntry();
 
170
 
 
171
//    int ret = 0;
 
172
//    if(inlCharToInteger(m_EditLine->GetCleanCaption().GetTChar(), ret))
 
173
//    {
 
174
//        m_iValue = ret;
 
175
//        if(m_iValue < m_IntValidator.GetMinimum())
 
176
//        {
 
177
//            m_iValue = m_IntValidator.GetMinimum();
 
178
//            m_EditLine->setCaption(inlPrintf("%d", m_iValue));
 
179
//        }
 
180
//        if(m_iValue > m_IntValidator.GetMaximum())
 
181
//        {
 
182
//            m_iValue = m_IntValidator.GetMaximum();
 
183
//            m_EditLine->setCaption(inlPrintf("%d", m_iValue));
 
184
//        }
 
185
//    }
 
186
//    else
 
187
//    {
 
188
//        m_EditLine->setCaption(inlPrintf("%d", m_iValue));
 
189
//    }
 
190
  }
 
191
 
 
192
}