nux-1.16.0
Vector3Valuator.cpp
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 "EditTextBox.h"
00026 #include "Vector3Valuator.h"
00027 
00028 namespace nux
00029 {
00030 
00031   Vector3Valuator::Vector3Valuator (NUX_FILE_LINE_DECL)
00032     :   View (NUX_FILE_LINE_PARAM)
00033   {
00034     m_Mouse = 0;
00035     m_XEdit = new EditTextBox (TEXT (""), NUX_TRACKER_LOCATION);
00036     m_YEdit = new EditTextBox (TEXT (""), NUX_TRACKER_LOCATION);
00037     m_ZEdit = new EditTextBox (TEXT (""), NUX_TRACKER_LOCATION);
00038     m_MouseControlledButton = new InputArea (NUX_TRACKER_LOCATION);
00039 
00040     // Set Original State
00041     m_XEdit->SetSuffix (TEXT ("") );
00042     m_XEdit->SetPrefix (TEXT ("") );
00043     m_YEdit->SetSuffix (TEXT ("") );
00044     m_YEdit->SetPrefix (TEXT ("") );
00045     m_ZEdit->SetSuffix (TEXT ("") );
00046     m_ZEdit->SetPrefix (TEXT ("") );
00047 
00048     // Set Signals
00049     m_MouseControlledButton->mouse_down.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvMouseDown) );
00050     m_MouseControlledButton->mouse_double_click.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvMouseDown) );
00051     m_MouseControlledButton->mouse_up.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvMouseUp) );
00052     m_MouseControlledButton->mouse_drag.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvMouseDrag) );
00053     m_MouseControlledButton->mouse_enter.connect (sigc::mem_fun (this, &Vector3Valuator::RecvMouseEnter) );
00054     m_MouseControlledButton->mouse_leave.connect (sigc::mem_fun (this, &Vector3Valuator::RecvMouseLeave) );
00055 
00056     m_XEdit->sigValidateEntry.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvValidateEntryX) );
00057     m_XEdit->sigStartKeyboardFocus.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvStartKeyboardFocus) );
00058     m_XEdit->sigEndKeyboardFocus.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvEndKeyboardFocus) );
00059     m_XEdit->sigEscapeKeyboardFocus.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvEscapeKeyboardFocus) );
00060     m_XEdit->sigEditChange.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvEditChange) );
00061     m_XEdit->mouse_enter.connect (sigc::mem_fun (this, &Vector3Valuator::RecvMouseEnter) );
00062     m_XEdit->mouse_leave.connect (sigc::mem_fun (this, &Vector3Valuator::RecvMouseLeave) );
00063 
00064     m_YEdit->sigValidateEntry.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvValidateEntryY) );
00065     m_YEdit->sigStartKeyboardFocus.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvStartKeyboardFocus) );
00066     m_YEdit->sigEndKeyboardFocus.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvEndKeyboardFocus) );
00067     m_YEdit->sigEscapeKeyboardFocus.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvEscapeKeyboardFocus) );
00068     m_YEdit->sigEditChange.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvEditChange) );
00069     m_YEdit->mouse_enter.connect (sigc::mem_fun (this, &Vector3Valuator::RecvMouseEnter) );
00070     m_YEdit->mouse_leave.connect (sigc::mem_fun (this, &Vector3Valuator::RecvMouseLeave) );
00071 
00072     m_ZEdit->sigValidateEntry.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvValidateEntryZ) );
00073     m_ZEdit->sigStartKeyboardFocus.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvStartKeyboardFocus) );
00074     m_ZEdit->sigEndKeyboardFocus.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvEndKeyboardFocus) );
00075     m_ZEdit->sigEscapeKeyboardFocus.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvEscapeKeyboardFocus) );
00076     m_ZEdit->sigEditChange.connect ( sigc::mem_fun (this, &Vector3Valuator::RecvEditChange) );
00077     m_ZEdit->mouse_enter.connect (sigc::mem_fun (this, &Vector3Valuator::RecvMouseEnter) );
00078     m_ZEdit->mouse_leave.connect (sigc::mem_fun (this, &Vector3Valuator::RecvMouseLeave) );
00079   }
00080 
00081   Vector3Valuator::~Vector3Valuator()
00082   {
00083 
00084   }
00085 
00086   void Vector3Valuator::RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags)
00087   {
00088     if ( (button_flags & NUX_STATE_BUTTON1_DOWN) && (button_flags & NUX_STATE_BUTTON3_DOWN) )
00089       m_Mouse = 2;
00090     else if (button_flags & NUX_EVENT_BUTTON1)
00091       m_Mouse = 1;
00092     else if (button_flags & NUX_EVENT_BUTTON3)
00093       m_Mouse = 3;
00094 
00095     QueueDraw();
00096   }
00097 
00098   void Vector3Valuator::RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags)
00099   {
00100     if ( (m_Mouse == 1) && (button_flags & NUX_EVENT_BUTTON1) )
00101       m_Mouse = 0;
00102     else if ( (m_Mouse == 3) && (button_flags & NUX_EVENT_BUTTON3) )
00103       m_Mouse = 0;
00104 
00105     QueueDraw();
00106   }
00107 
00108   void Vector3Valuator::RecvDecrement (int x, int y, unsigned long button_flags, unsigned long key_flags)
00109   {
00110     TimerSpinDownBtn (0);
00111   }
00112 
00113   void Vector3Valuator::TimerSpinUpBtn (void *v)
00114   {
00115   }
00116 
00117   void Vector3Valuator::TimerSpinDownBtn (void *v)
00118   {
00119   }
00120 
00121   void Vector3Valuator::RecvStartKeyboardFocus (EditTextBox *textbox)
00122   {
00123     QueueDraw();
00124   }
00125 
00126   void Vector3Valuator::RecvEndKeyboardFocus (EditTextBox *textbox)
00127   {
00128     QueueDraw();
00129   }
00130 
00131   void Vector3Valuator::RecvEscapeKeyboardFocus (EditTextBox *textbox)
00132   {
00133     QueueDraw();
00134   }
00135 
00136   void Vector3Valuator::RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)
00137   {
00138     QueueDraw();
00139   }
00140 
00141   void Vector3Valuator::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)
00142   {
00143     QueueDraw();
00144   }
00145 
00146   void Vector3Valuator::RecvMouseMove (int x, int y, unsigned long button_flags, unsigned long key_flags)
00147   {
00148     QueueDraw();
00149   }
00150 
00151   void Vector3Valuator::RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
00152   {
00153     if (m_Mouse == 2)
00154     {
00155       if (dy > 0)
00156         ImplementDecrementZ();
00157 
00158       if (dy < 0)
00159         ImplementIncrementZ();
00160     }
00161     else if (m_Mouse == 1)
00162     {
00163       if (dy > 0)
00164         ImplementDecrementX();
00165 
00166       if (dy < 0)
00167         ImplementIncrementX();
00168     }
00169     else if (m_Mouse == 3)
00170     {
00171       if (dy > 0)
00172         ImplementDecrementY();
00173 
00174       if (dy < 0)
00175         ImplementIncrementY();
00176     }
00177 
00178     QueueDraw();
00179   }
00180 
00181   void Vector3Valuator::RecvEditChange (EditTextBox *textbox)
00182   {
00183     QueueDraw();
00184   }
00185 
00186   void Vector3Valuator::RecvValidateEntryX (EditTextBox *textbox)
00187   {
00188     ImplementValidateEntryX();
00189   }
00190 
00191   void Vector3Valuator::RecvValidateEntryY (EditTextBox *textbox)
00192   {
00193     ImplementValidateEntryY();
00194   }
00195 
00196   void Vector3Valuator::RecvValidateEntryZ (EditTextBox *textbox)
00197   {
00198     ImplementValidateEntryZ();
00199   }
00200 
00201 
00202 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends