Back to index

nux  3.0.0
TestTextEntry.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2012 Inalogic Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU General Public License version 3, as published
00006  * by the  Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * version 3 along with this program.  If not, see
00015  * <http://www.gnu.org/licenses/>
00016  *
00017  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00018  *
00019  */
00020 
00021 #include "Nux/Nux.h"
00022 #include "TestTextEntry.h"
00023 
00024 /*
00025   TestTextEntry:
00026     This class is a Nux view that processes all mouse events that it receives. It is meant for testing simulated
00027     mouse events. 
00028 */
00029 namespace nux {
00030 NUX_IMPLEMENT_OBJECT_TYPE(TestTextEntry);
00031 
00032 TestTextEntry::TestTextEntry(NUX_FILE_LINE_DECL)
00033 : nux::TextEntry("", NUX_FILE_LINE_PARAM)
00034 {
00035   ResetEvents();
00036   ResetKeyFocusEvents();
00037 
00038   key_nav_direction_ = nux::KEY_NAV_NONE;
00039 
00040   has_focus_ = false;
00041   mouse_in_ = false;
00042   mouse_mouse_drag_ = false;
00043   mouse_mouse_down_ = false;
00044 
00045   mouse_down.connect(sigc::mem_fun(this, &TestTextEntry::OnMouseDown));
00046   mouse_up.connect(sigc::mem_fun(this, &TestTextEntry::OnMouseUp));
00047   mouse_drag.connect(sigc::mem_fun(this, &TestTextEntry::OnMouseDrag));
00048   mouse_click.connect(sigc::mem_fun(this, &TestTextEntry::OnMouseClick));
00049   mouse_double_click.connect(sigc::mem_fun(this, &TestTextEntry::OnMouseDoubleClick));
00050   mouse_move.connect(sigc::mem_fun(this, &TestTextEntry::OnMouseMove));
00051   mouse_enter.connect(sigc::mem_fun(this, &TestTextEntry::OnMouseEnter));
00052   mouse_leave.connect(sigc::mem_fun(this, &TestTextEntry::OnMouseLeave));
00053   key_nav_focus_change.connect(sigc::mem_fun(this, &TestTextEntry::OnKeyNavFocusChange));
00054   begin_key_focus.connect(sigc::mem_fun(this, &TestTextEntry::OnBeginKeyFocus));
00055   end_key_focus.connect(sigc::mem_fun(this, &TestTextEntry::OnEndKeyFocus));
00056   object_destroyed.connect(sigc::mem_fun(this, &TestTextEntry::OnObjectDestroyed));
00057 
00058   text_changed.connect(sigc::mem_fun(this, &TestTextEntry::OnTextChanged));
00059 
00060 
00061 }
00062 
00063 TestTextEntry::~TestTextEntry()
00064 {
00065 
00066 }
00067 
00068 void TestTextEntry::ResetEvents()
00069 {
00070   registered_mouse_down_          = false;
00071   registered_mouse_up_            = false;
00072   registered_mouse_drag_          = false;
00073   registered_mouse_enter_         = false;
00074   registered_mouse_leave_         = false;
00075   registered_mouse_click_         = false;
00076   registered_mouse_double_click_  = false;
00077   registered_mouse_move_          = false;
00078   registered_mouse_enter_         = false;
00079   registered_mouse_leave_         = false;
00080   registered_object_destroyed_    = false;
00081   registered_text_changed_        = false;
00082 }
00083 
00084 void TestTextEntry::ResetKeyFocusEvents()
00085 {
00086   registered_begin_keynav_focus_ = false;
00087   registered_end_keynav_focus_ = false;
00088 }
00089 
00090 void TestTextEntry::OnMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)
00091 {
00092   registered_mouse_down_ = true;
00093   mouse_mouse_down_ = true;
00094   QueueDraw();
00095 }
00096 
00097 void TestTextEntry::OnMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags)
00098 {
00099   registered_mouse_up_ = true;
00100 
00101   mouse_mouse_down_ = false;
00102   mouse_mouse_drag_ = false;
00103   QueueDraw();
00104 }
00105 
00106 void TestTextEntry::OnMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
00107 {
00108   registered_mouse_drag_ = true;
00109   mouse_mouse_drag_ = true;
00110   QueueDraw();
00111 }
00112 
00113 void TestTextEntry::OnMouseClick(int x, int y, unsigned long button_flags, unsigned long key_flags)
00114 {
00115   registered_mouse_click_ = true;
00116   QueueDraw();
00117 }
00118 
00119 void TestTextEntry::OnMouseDoubleClick(int x, int y, unsigned long button_flags, unsigned long key_flags)
00120 {
00121   registered_mouse_double_click_ = true;
00122   mouse_mouse_down_ = true;
00123   QueueDraw();
00124 }
00125 
00126 void TestTextEntry::OnMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
00127 {
00128   registered_mouse_move_ = true;
00129   QueueDraw();
00130 }
00131 
00132 void TestTextEntry::OnMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags)
00133 {
00134   registered_mouse_enter_ = true;
00135   mouse_in_ = true;
00136   QueueDraw();
00137 }
00138 
00139 void TestTextEntry::OnMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags)
00140 {
00141   registered_mouse_leave_ = true;
00142   mouse_in_ = false;
00143   QueueDraw();
00144 }
00145 
00146 void TestTextEntry::OnKeyNavFocusChange(nux::Area* area, bool has_focus, nux::KeyNavDirection direction)
00147 {
00148   has_focus_ = HasKeyFocus();
00149   
00150   has_focus_ = has_focus;
00151   key_nav_direction_ = direction;
00152   QueueDraw();
00153 }
00154 
00155 void TestTextEntry::OnBeginKeyFocus()
00156 {
00157   registered_begin_keynav_focus_ = true;
00158 }
00159 
00160 void TestTextEntry::OnEndKeyFocus()
00161 {
00162   registered_end_keynav_focus_ = true;
00163 }
00164 
00165 void TestTextEntry::OnObjectDestroyed(nux::Object* object)
00166 {
00167   registered_object_destroyed_ = true;
00168 }
00169 
00170 void TestTextEntry::OnTextChanged(TextEntry* text_entry)
00171 {
00172   registered_text_changed_ = true;
00173 }
00174 
00175 }