2
* Copyright 2010 Inalogic Inc.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3, as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the applicable version of the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of both the GNU Lesser General Public
15
* License version 3 along with this program. If not, see
16
* <http://www.gnu.org/licenses/>
18
* Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
26
#include "BaseObject.h"
27
#include "MouseHandler.h"
29
#if defined(INL_OS_WINDOWS)
30
#include "NuxGraphics/Gfx_Events.h"
31
#elif defined(INL_OS_LINUX)
32
#include "NuxGraphics/GfxEventsX11.h"
43
////////////////////////////////////////////////////////////////////////////
45
////////////////////////////////////////////////////////////////////////////
48
typedef BaseArea CoreArea;
50
class BaseArea : public BaseObject //public sigc::trackable
53
DECLARE_OBJECT_TYPE(BaseArea, BaseObject);
60
m_MouseEventCurrent.MouseIn = false;
63
void ForceStartFocus(int x, int y);
64
void ForceStopFocus(int x, int y);
66
virtual long OnEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
70
Draw a colored quad using m_AreaColor.
71
Override this function to define a custom drawing function.
72
If force_draw is true then the system requests that all objects redraw themselves completely.
75
virtual void OnDraw(GraphicsContext& GfxContext, bool force_draw);
77
virtual void OverlayDrawing(GraphicsContext& GfxContext) {}
79
bool HasKeyboardFocus();
80
void SetKeyboardFocus(bool b);
85
bool MouseFocusOnOtherArea();
86
void CaptureMouseDownAnyWhereElse(bool b);
87
bool IsCaptureMouseDownAnyWhereElse() const;
90
//bool m_EnableKeyboardInput;
92
// void EnableKeyEntry(bool b)
94
// m_EnableKeyboardInput = true;
97
// bool IsEnableKeyEntry()
99
// return m_EnableKeyboardInput; //m_KeyboardHandler.IsEnableKeyEntry();
102
// Override the virtual methods from Object Base
103
// Here, we get a change to update the text of the keyboard handler.
104
virtual void SetBaseString(const TCHAR* Caption);
106
void EnableDoubleClick(bool b);
107
bool IsDoubleClickEnabled();
108
void EnableUserKeyboardProcessing(bool b);
109
bool IsUserKeyboardProcessingEnabled();
111
virtual bool IsArea() const {return true;}
113
unsigned short getKeyState(int nVirtKey);
115
// This method reset the mouse position inside the Area. This is necessary for areas that serve as Drag
116
// when the area position is reffered to (x_root, y_root) instead of being the system window coordinates (0, 0).
117
void SetAreaMousePosition(int x, int y);
121
//! Color of the CoreArea
123
Color of the CoreArea use to draw a colored quad when OnDraw() is called.
128
struct MouseEvent m_MouseEventPrevious;
129
struct MouseEvent m_MouseEventCurrent;
131
BaseMouseHandler m_EventHandler;
133
bool m_hasKeyboardFocus;
134
bool m_CaptureMouseDownAnyWhereElse;
135
bool m_EnableDoubleClick;
136
bool m_EnableUserKeyboardProcessing;
139
sigc::signal<void, int, int, int, int, unsigned long, unsigned long> OnMouseMove; // send the current position inside the area
140
sigc::signal<void, int, int, unsigned long, unsigned long> OnMouseDown;
141
sigc::signal<void, int, int, unsigned long, unsigned long> OnMouseUp;
142
sigc::signal<void, int, int, unsigned long, unsigned long> OnMouseEnter;
143
sigc::signal<void, int, int, unsigned long, unsigned long> OnMouseLeave;
144
sigc::signal<void, int, int, unsigned long, unsigned long> OnMouseClick;
145
sigc::signal<void, int, int, unsigned long, unsigned long> OnMouseDoubleClick;
146
sigc::signal<void, int, int, int, int, unsigned long, unsigned long> OnMouseDrag; // send (current X, current Y, delta X, delta Y)
151
int, // mouse wheel delta: +120/-120 correspond to one notch of the wheel
152
unsigned long, // mouse state
153
unsigned long // key state
154
> OnMouseWheel; // send (current X, current Y, delta X, delta Y)
156
sigc::signal<void, unsigned int, unsigned long, unsigned long> OnKeyPressed;
157
sigc::signal<void, unsigned int, unsigned long, unsigned long> OnKeyReleased;
158
sigc::signal<void> OnValidateKeyboardEntry;
160
//! Signal emitted when the area gets the mouse focus. This is the result of a mouse down event.
161
sigc::signal<void> OnStartMouseFocus;
162
//! Signal emitted when the mouse is released. The area that had the mouse focus receives this signal.
163
//! Note that the area may still have the keyboard focus after OnEndMouseFocus is emitted.
164
sigc::signal<void> OnEndMouseFocus;
166
//! Signal emitted when the area gets the keyboard focus. The is a result of a mouse down event or a call to ForceStartFocus.
167
sigc::signal<void> OnStartFocus;
168
//! Signal emitted when the area looses the keyboard focus.
169
sigc::signal<void> OnEndFocus;
172
GraphicsContext& , /*Graphics Context for text operation*/
173
unsigned long , /*event type*/
174
unsigned long , /*event keysym*/
175
unsigned long , /*event state*/
176
const char* , /*character*/
177
bool , /*true if the key is repeated more than once*/
178
unsigned short /*key repeat count*/
181
sigc::signal<void, int, int, unsigned long, unsigned long> OnCaptureMouseDownAnyWhereElse;