nux-0.9.48

Nux/MouseHandler.h

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 #ifndef AREAEVENTPROCESSOR_H
00024 #define AREAEVENTPROCESSOR_H
00025 
00026 #include "NuxGraphics/Events.h"
00027 #include "Utils.h"
00028 
00029 namespace nux
00030 {
00032   typedef enum
00033   {
00034     AREA_MOUSE_STATUS_NONE   = 0L,
00035     AREA_MOUSE_STATUS_DOWN   = (1L << 0),   
00036     AREA_MOUSE_STATUS_UP     = (1L << 1),   
00037     AREA_MOUSE_STATUS_FOCUS  = (1L << 2),   
00038     AREA_MOUSE_STATUS_MOVE   = (1L << 3),   
00039     AREA_MOUSE_STATUS_ENTER  = (1L << 4),   
00040     AREA_MOUSE_STATUS_LEAVE  = (1L << 5),   
00041   } AreaMouseStatus;
00042 
00043   class AreaEventProcessor
00044   {
00045   public:
00046     AreaEventProcessor();
00047     ~AreaEventProcessor();
00048 
00058     unsigned int EventProcessor (Event &event, const Geometry &g, bool process_mouse_focus);
00059 
00060     bool MouseIn();
00061 
00062     void ForceMouseFocus (int x, int y, const Geometry &g);
00063     void StopMouseFocus (int x, int y, const Geometry &g);
00064 
00065   private:
00066 
00068     void ResetState ();
00069 
00070     bool _has_mouse_focus;
00071     bool _previous_mouse_in;
00072     bool _current_mouse_in;
00073     unsigned int _state;
00074 
00076     int _mouse_positionx;
00078     int _mouse_positiony;
00080     int _mouse_deltax;
00082     int _mouse_deltay;
00083 
00084     bool _initial_state;
00085 
00086     friend class InputArea;
00087   };
00088 }
00089 
00090 #endif // AREAEVENTPROCESSOR_H