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 "MouseAreaCtrl.h" 00025 00026 namespace nux 00027 { 00028 00029 MouseAreaCtrl::MouseAreaCtrl (NUX_FILE_LINE_DECL) 00030 : View (NUX_FILE_LINE_PARAM) 00031 { 00032 // Set Original State 00033 m_vlayout = new VLayout (NUX_TRACKER_LOCATION); 00034 m_Area = new InputArea (NUX_TRACKER_LOCATION); 00035 00036 // Set Signals 00037 m_Area->mouse_down.connect (sigc::mem_fun (this, &MouseAreaCtrl::MouseDown) ); 00038 m_Area->mouse_up.connect (sigc::mem_fun (this, &MouseAreaCtrl::MouseUp) ); 00039 m_Area->mouse_drag.connect (sigc::mem_fun (this, &MouseAreaCtrl::MouseDrag) ); 00040 00041 // Set Geometry 00042 m_Area->SetMinimumSize (100, 100); 00043 m_Area->SetGeometry (Geometry (0, 0, 200, 400) ); 00044 00045 m_vlayout->AddView (m_Area, 1); 00046 m_vlayout->SetVerticalExternalMargin (6); 00047 m_vlayout->SetHorizontalExternalMargin (6); 00048 SetCompositionLayout (m_vlayout); 00049 } 00050 00051 MouseAreaCtrl::~MouseAreaCtrl() 00052 { 00053 } 00054 00055 long MouseAreaCtrl::ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo) 00056 { 00057 long ret = TraverseInfo; 00058 ret = m_Area->OnEvent (ievent, ret, ProcessEventInfo); 00059 ret = PostProcessEvent2 (ievent, ret, ProcessEventInfo); 00060 00061 QueueDraw(); 00062 return ret; 00063 } 00064 00065 void MouseAreaCtrl::Draw (GraphicsEngine &GfxContext, bool force_draw) 00066 { 00067 Geometry base = GetGeometry(); 00068 GetPainter().PaintShape (GfxContext, base, Color (COLOR_BACKGROUND_SECONDARY), eSHAPE_CORNER_ROUND10); 00069 00070 sigDraw.emit (force_draw); 00071 } 00072 00073 void MouseAreaCtrl::DrawContent (GraphicsEngine &GfxContext, bool force_draw) 00074 { 00075 sigDraw.emit (force_draw); 00076 } 00077 00078 void MouseAreaCtrl::PostDraw (GraphicsEngine &GfxContext, bool force_draw) 00079 { 00080 00081 } 00082 00083 int MouseAreaCtrl::getAreaPosX() 00084 { 00085 return m_Area->GetBaseX(); 00086 } 00087 int MouseAreaCtrl::getAreaPosY() 00088 { 00089 return m_Area->GetBaseY(); 00090 } 00091 int MouseAreaCtrl::getAreaWidth() 00092 { 00093 return m_Area->GetBaseWidth(); 00094 } 00095 int MouseAreaCtrl::getAreaHeight() 00096 { 00097 return m_Area->GetBaseHeight(); 00098 } 00099 00101 // EMITERS // 00103 void MouseAreaCtrl::MouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags) 00104 { 00105 sigMouseDown.emit (x, y, button_flags); 00106 } 00107 void MouseAreaCtrl::MouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags) 00108 { 00109 sigMouseUp.emit (x, y, button_flags); 00110 } 00111 void MouseAreaCtrl::MouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags) 00112 { 00113 sigMouseDrag.emit (x, y, dx, dy, button_flags); 00114 } 00115 00116 00117 00118 }