Back to index

nux  3.0.0
MouseAreaCtrl.cpp
Go to the documentation of this file.
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   void MouseAreaCtrl::Draw(GraphicsEngine &graphics_engine, bool force_draw)
00056   {
00057     Geometry base = GetGeometry();
00058     GetPainter().PaintShape(graphics_engine, base, Color(COLOR_BACKGROUND_SECONDARY),  eSHAPE_CORNER_ROUND10);
00059 
00060     sigDraw.emit(force_draw);
00061   }
00062 
00063   void MouseAreaCtrl::DrawContent(GraphicsEngine &graphics_engine, bool force_draw)
00064   {
00065     sigDraw.emit(force_draw);
00066   }
00067 
00068   void MouseAreaCtrl::PostDraw(GraphicsEngine &graphics_engine, bool force_draw)
00069   {
00070 
00071   }
00072 
00073   int MouseAreaCtrl::getAreaPosX()
00074   {
00075     return m_Area->GetBaseX();
00076   }
00077   int MouseAreaCtrl::getAreaPosY()
00078   {
00079     return m_Area->GetBaseY();
00080   }
00081   int MouseAreaCtrl::getAreaWidth()
00082   {
00083     return m_Area->GetBaseWidth();
00084   }
00085   int MouseAreaCtrl::getAreaHeight()
00086   {
00087     return m_Area->GetBaseHeight();
00088   }
00089 
00091 //  EMITERS    //
00093   void MouseAreaCtrl::MouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)
00094   {
00095     sigMouseDown.emit(x, y, button_flags);
00096   }
00097   void MouseAreaCtrl::MouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags)
00098   {
00099     sigMouseUp.emit(x, y, button_flags);
00100   }
00101   void MouseAreaCtrl::MouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
00102   {
00103     sigMouseDrag.emit(x, y, dx, dy, button_flags);
00104   }
00105 
00106 
00107 
00108 }