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 "TimerProc.h"
25
#include "SpinBox_Logic.h"
30
SpinBox_Logic::SpinBox_Logic (NUX_FILE_LINE_DECL)
31
: View (NUX_FILE_LINE_PARAM)
32
, m_UpTimerHandler (0)
33
, m_DownTimerHandler (0)
39
SpinBox_Logic::~SpinBox_Logic()
44
void SpinBox_Logic::InitializeWidgets()
47
m_EditLine->SetSuffix (TEXT ("") );
48
m_EditLine->SetPrefix (TEXT ("") );
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) );
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) );
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) );
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) );
79
void SpinBox_Logic::InitializeLayout()
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);
86
void SpinBox_Logic::DestroyLayout()
90
void SpinBox_Logic::RecvIncrement (int x, int y, unsigned long button_flags, unsigned long key_flags)
95
void SpinBox_Logic::RecvSpinnerMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags)
97
if (m_UpTimerHandler.IsValid() )
99
GetTimer().RemoveTimerHandler (m_UpTimerHandler);
100
m_UpTimerHandler = 0;
103
if (m_DownTimerHandler.IsValid() )
105
GetTimer().RemoveTimerHandler (m_DownTimerHandler);
106
m_DownTimerHandler = 0;
112
void SpinBox_Logic::RecvDecrement (int x, int y, unsigned long button_flags, unsigned long key_flags)
114
TimerSpinDownBtn (0);
117
void SpinBox_Logic::TimerSpinUpBtn (void *v)
119
ImplementIncrementBtn();
122
void SpinBox_Logic::TimerSpinDownBtn (void *v)
124
ImplementDecrementBtn();
127
void SpinBox_Logic::RecvStartKeyboardFocus (EditTextBox *textbox)
132
void SpinBox_Logic::RecvEndKeyboardFocus (EditTextBox *textbox)
137
void SpinBox_Logic::RecvEscapeKeyboardFocus (EditTextBox *textbox)
142
void SpinBox_Logic::RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)
147
void SpinBox_Logic::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)
152
void SpinBox_Logic::RecvMouseMove (int x, int y, unsigned long button_flags, unsigned long key_flags)
157
void SpinBox_Logic::RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
162
void SpinBox_Logic::RecvEditChange (EditTextBox *textbox)
167
void SpinBox_Logic::RecvValidateEntry (EditTextBox *textbox)
169
ImplementValidateEntry();
172
// if(inlCharToInteger(m_EditLine->GetCleanCaption().GetTChar(), ret))
175
// if(m_iValue < m_IntValidator.GetMinimum())
177
// m_iValue = m_IntValidator.GetMinimum();
178
// m_EditLine->setCaption(inlPrintf("%d", m_iValue));
180
// if(m_iValue > m_IntValidator.GetMaximum())
182
// m_iValue = m_IntValidator.GetMaximum();
183
// m_EditLine->setCaption(inlPrintf("%d", m_iValue));
188
// m_EditLine->setCaption(inlPrintf("%d", m_iValue));
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 <jaytaoko@inalogic.com>
24
#include "TimerProc.h"
25
#include "SpinBox_Logic.h"
30
SpinBox_Logic::SpinBox_Logic (NUX_FILE_LINE_DECL)
31
: View (NUX_FILE_LINE_PARAM)
32
, m_UpTimerHandler (0)
33
, m_DownTimerHandler (0)
39
SpinBox_Logic::~SpinBox_Logic()
44
void SpinBox_Logic::InitializeWidgets()
47
m_EditLine->SetSuffix (TEXT ("") );
48
m_EditLine->SetPrefix (TEXT ("") );
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) );
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) );
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) );
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) );
79
void SpinBox_Logic::InitializeLayout()
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);
86
void SpinBox_Logic::DestroyLayout()
90
void SpinBox_Logic::RecvIncrement (int x, int y, unsigned long button_flags, unsigned long key_flags)
95
void SpinBox_Logic::RecvSpinnerMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags)
97
if (m_UpTimerHandler.IsValid() )
99
GetTimer().RemoveTimerHandler (m_UpTimerHandler);
100
m_UpTimerHandler = 0;
103
if (m_DownTimerHandler.IsValid() )
105
GetTimer().RemoveTimerHandler (m_DownTimerHandler);
106
m_DownTimerHandler = 0;
112
void SpinBox_Logic::RecvDecrement (int x, int y, unsigned long button_flags, unsigned long key_flags)
114
TimerSpinDownBtn (0);
117
void SpinBox_Logic::TimerSpinUpBtn (void *v)
119
ImplementIncrementBtn();
122
void SpinBox_Logic::TimerSpinDownBtn (void *v)
124
ImplementDecrementBtn();
127
void SpinBox_Logic::RecvStartKeyboardFocus (EditTextBox *textbox)
132
void SpinBox_Logic::RecvEndKeyboardFocus (EditTextBox *textbox)
137
void SpinBox_Logic::RecvEscapeKeyboardFocus (EditTextBox *textbox)
142
void SpinBox_Logic::RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)
147
void SpinBox_Logic::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)
152
void SpinBox_Logic::RecvMouseMove (int x, int y, unsigned long button_flags, unsigned long key_flags)
157
void SpinBox_Logic::RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
162
void SpinBox_Logic::RecvEditChange (EditTextBox *textbox)
167
void SpinBox_Logic::RecvValidateEntry (EditTextBox *textbox)
169
ImplementValidateEntry();
172
// if(inlCharToInteger(m_EditLine->GetCleanCaption().GetTChar(), ret))
175
// if(m_iValue < m_IntValidator.GetMinimum())
177
// m_iValue = m_IntValidator.GetMinimum();
178
// m_EditLine->setCaption(inlPrintf("%d", m_iValue));
180
// if(m_iValue > m_IntValidator.GetMaximum())
182
// m_iValue = m_IntValidator.GetMaximum();
183
// m_EditLine->setCaption(inlPrintf("%d", m_iValue));
188
// m_EditLine->setCaption(inlPrintf("%d", m_iValue));