nux-1.16.0
|
00001 /* 00002 * Copyright 2010 Inalogic® Inc. 00003 * 00004 * This program is free software: you can redistribute it and/or modify it 00005 * under the terms of the GNU Lesser General Public License, as 00006 * published by the Free Software Foundation; either version 2.1 or 3.0 00007 * of the License. 00008 * 00009 * This program is distributed in the hope that it will be useful, but 00010 * WITHOUT ANY WARRANTY; without even the implied warranties of 00011 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 00012 * PURPOSE. See the applicable version of the GNU Lesser General Public 00013 * License for more details. 00014 * 00015 * You should have received a copy of both the GNU Lesser General Public 00016 * License along with this program. If not, see <http://www.gnu.org/licenses/> 00017 * 00018 * Authored by: Jay Taoko <jaytaoko@inalogic.com> 00019 * 00020 */ 00021 00022 00023 #include "Nux.h" 00024 #include "TimerProc.h" 00025 #include "SpinBox_Logic.h" 00026 00027 namespace nux 00028 { 00029 00030 SpinBox_Logic::SpinBox_Logic (NUX_FILE_LINE_DECL) 00031 : View (NUX_FILE_LINE_PARAM) 00032 , m_UpTimerHandler (0) 00033 , m_DownTimerHandler (0) 00034 { 00035 m_SpinnerUpBtn = new InputArea (NUX_TRACKER_LOCATION); 00036 m_SpinnerDownBtn = new InputArea (NUX_TRACKER_LOCATION); 00037 m_EditLine = new EditTextBox (TEXT (""), NUX_TRACKER_LOCATION); 00038 00039 // Set Original State 00040 m_EditLine->SetSuffix (TEXT ("") ); 00041 m_EditLine->SetPrefix (TEXT ("") ); 00042 00043 // Set Signals 00044 m_SpinnerUpBtn->mouse_down.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvIncrement) ); 00045 m_SpinnerUpBtn->mouse_double_click.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvIncrement) ); 00046 m_SpinnerUpBtn->mouse_up.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvSpinnerMouseUp) ); 00047 m_SpinnerUpBtn->mouse_click.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvSpinnerMouseUp) ); 00048 m_SpinnerUpBtn->mouse_enter.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseEnter) ); 00049 m_SpinnerUpBtn->mouse_leave.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseLeave) ); 00050 00051 m_SpinnerDownBtn->mouse_down.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvDecrement) ); 00052 m_SpinnerDownBtn->mouse_double_click.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvDecrement) ); 00053 m_SpinnerDownBtn->mouse_up.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvSpinnerMouseUp) ); 00054 m_SpinnerDownBtn->mouse_click.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvSpinnerMouseUp) ); 00055 m_SpinnerDownBtn->mouse_enter.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseEnter) ); 00056 m_SpinnerDownBtn->mouse_leave.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseLeave) ); 00057 00058 m_EditLine->sigValidateEntry.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvValidateEntry) ); 00059 m_EditLine->sigStartKeyboardFocus.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvStartKeyboardFocus) ); 00060 m_EditLine->sigEndKeyboardFocus.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvEndKeyboardFocus) ); 00061 m_EditLine->sigEscapeKeyboardFocus.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvEscapeKeyboardFocus) ); 00062 m_EditLine->sigEditChange.connect ( sigc::mem_fun (this, &SpinBox_Logic::RecvEditChange) ); 00063 m_EditLine->mouse_enter.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseEnter) ); 00064 m_EditLine->mouse_leave.connect (sigc::mem_fun (this, &SpinBox_Logic::RecvMouseLeave) ); 00065 00066 m_UpTimerCallback = new TimerFunctor; 00067 m_UpTimerCallback->OnTimerExpired.connect (sigc::mem_fun (this, &SpinBox_Logic::TimerSpinUpBtn) ); 00068 m_DownTimerCallback = new TimerFunctor; 00069 m_DownTimerCallback->OnTimerExpired.connect (sigc::mem_fun (this, &SpinBox_Logic::TimerSpinDownBtn) ); 00070 } 00071 00072 SpinBox_Logic::~SpinBox_Logic() 00073 { 00074 delete m_UpTimerCallback; 00075 delete m_DownTimerCallback; 00076 // m_SpinnerUpBtn->Dispose(); 00077 // m_SpinnerDownBtn->Dispose(); 00078 // m_EditLine->Dispose(); 00079 } 00080 00081 void SpinBox_Logic::RecvIncrement (int x, int y, unsigned long button_flags, unsigned long key_flags) 00082 { 00083 TimerSpinUpBtn (0); 00084 } 00085 00086 void SpinBox_Logic::RecvSpinnerMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags) 00087 { 00088 if (m_UpTimerHandler.IsValid() ) 00089 { 00090 GetTimer().RemoveTimerHandler (m_UpTimerHandler); 00091 m_UpTimerHandler = 0; 00092 } 00093 00094 if (m_DownTimerHandler.IsValid() ) 00095 { 00096 GetTimer().RemoveTimerHandler (m_DownTimerHandler); 00097 m_DownTimerHandler = 0; 00098 } 00099 00100 QueueDraw(); 00101 } 00102 00103 void SpinBox_Logic::RecvDecrement (int x, int y, unsigned long button_flags, unsigned long key_flags) 00104 { 00105 TimerSpinDownBtn (0); 00106 } 00107 00108 void SpinBox_Logic::TimerSpinUpBtn (void *v) 00109 { 00110 ImplementIncrementBtn(); 00111 } 00112 00113 void SpinBox_Logic::TimerSpinDownBtn (void *v) 00114 { 00115 ImplementDecrementBtn(); 00116 } 00117 00118 void SpinBox_Logic::RecvStartKeyboardFocus (EditTextBox *textbox) 00119 { 00120 QueueDraw(); 00121 } 00122 00123 void SpinBox_Logic::RecvEndKeyboardFocus (EditTextBox *textbox) 00124 { 00125 QueueDraw(); 00126 } 00127 00128 void SpinBox_Logic::RecvEscapeKeyboardFocus (EditTextBox *textbox) 00129 { 00130 QueueDraw(); 00131 } 00132 00133 void SpinBox_Logic::RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags) 00134 { 00135 QueueDraw(); 00136 } 00137 00138 void SpinBox_Logic::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags) 00139 { 00140 QueueDraw(); 00141 } 00142 00143 void SpinBox_Logic::RecvMouseMove (int x, int y, unsigned long button_flags, unsigned long key_flags) 00144 { 00145 QueueDraw(); 00146 } 00147 00148 void SpinBox_Logic::RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags) 00149 { 00150 QueueDraw(); 00151 } 00152 00153 void SpinBox_Logic::RecvEditChange (EditTextBox *textbox) 00154 { 00155 QueueDraw(); 00156 } 00157 00158 void SpinBox_Logic::RecvValidateEntry (EditTextBox *textbox) 00159 { 00160 ImplementValidateEntry(); 00161 00162 // int ret = 0; 00163 // if(inlCharToInteger(m_EditLine->GetCleanCaption().GetTChar(), ret)) 00164 // { 00165 // m_iValue = ret; 00166 // if(m_iValue < m_IntValidator.GetMinimum()) 00167 // { 00168 // m_iValue = m_IntValidator.GetMinimum(); 00169 // m_EditLine->setCaption(NString::Printf("%d", m_iValue)); 00170 // } 00171 // if(m_iValue > m_IntValidator.GetMaximum()) 00172 // { 00173 // m_iValue = m_IntValidator.GetMaximum(); 00174 // m_EditLine->setCaption(NString::Printf("%d", m_iValue)); 00175 // } 00176 // } 00177 // else 00178 // { 00179 // m_EditLine->setCaption(NString::Printf("%d", m_iValue)); 00180 // } 00181 } 00182 00183 }