PageRenderTime 384ms CodeModel.GetById 161ms app.highlight 6ms RepoModel.GetById 215ms app.codeStats 0ms

/src/ftk_event.h

http://ftk.googlecode.com/
C++ Header | 143 lines | 103 code | 11 blank | 29 comment | 2 complexity | 0096da0428daba81de3041e0457cd376 MD5 | raw file
  1/*
  2 * File: ftk_event.h    
  3 * Author:  Li XianJing <xianjimli@hotmail.com>
  4 * Brief:   
  5 *
  6 * Copyright (c) 2009 - 2010  Li XianJing <xianjimli@hotmail.com>
  7 *
  8 * Licensed under the Academic Free License version 2.1
  9 *
 10 * This program is free software; you can redistribute it and/or modify
 11 * it under the terms of the GNU General Public License as published by
 12 * the Free Software Foundation; either version 2 of the License, or
 13 * (at your option) any later version.
 14 *
 15 * This program is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 18 * GNU General Public License for more details.
 19 *
 20 * You should have received a copy of the GNU General Public License
 21 * along with this program; if not, write to the Free Software
 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 23 */
 24
 25/*
 26 * History:
 27 * ================================================================
 28 * 2009-10-03 Li XianJing <xianjimli@hotmail.com> created
 29 *
 30 */
 31#ifndef FTK_EVENT_H
 32#define FTK_EVENT_H
 33#include "ftk_typedef.h"
 34
 35FTK_BEGIN_DECLS
 36
 37typedef enum _FtkEventType
 38{
 39	FTK_EVT_NOP = 0,
 40	FTK_EVT_IDLE,
 41	FTK_EVT_INIT,
 42	FTK_EVT_TIMER,
 43	FTK_EVT_QUIT,
 44	FTK_EVT_KEY_UP,
 45	FTK_EVT_KEY_DOWN,
 46	FTK_EVT_MOUSE_MOVE,
 47	FTK_EVT_MOUSE_DOWN,
 48	FTK_EVT_MOUSE_LONG_PRESS,
 49	FTK_EVT_KEY_LONG_PRESS,
 50	FTK_EVT_MOUSE_UP,
 51	FTK_EVT_HIDE,
 52	FTK_EVT_SHOW,
 53	FTK_EVT_MAP,
 54	FTK_EVT_UNMAP,
 55	FTK_EVT_UPDATE,
 56	FTK_EVT_MOVE,
 57	FTK_EVT_RESIZE,
 58	FTK_EVT_MOVE_RESIZE,
 59	FTK_EVT_FOCUS_IN,
 60	FTK_EVT_FOCUS_OUT,
 61	FTK_EVT_ADD_CHILD,
 62	FTK_EVT_IM_COMMIT,
 63	FTK_EVT_IM_PREEDIT,
 64	FTK_EVT_SET_TEXT,
 65	FTK_EVT_GET_TEXT,
 66	FTK_EVT_IM_ACT_COMMIT,
 67	FTK_EVT_OS_IM_COMMIT,
 68	FTK_EVT_REMOVE_CHILD,
 69	FTK_EVT_WND_DESTROY,
 70	FTK_EVT_RELAYOUT_WND,
 71	FTK_EVT_ADD_SOURCE,
 72	FTK_EVT_REMOVE_SOURCE,
 73	FTK_EVT_THEME_CHANGED,
 74	FTK_EVT_SCREEN_ROTATED,
 75	FTK_EVT_DISABLE_CURSOR,
 76	FTK_EVT_ENABLE_CURSOR,
 77	FTK_EVT_OS_SCREEN_ROTATED,
 78	FTK_EVT_LOCALE_CHANGED,
 79	FTK_EVT_DISPLAY_CHANGED, 
 80	FTK_EVT_TOP_WND_CHANGED,
 81	FTK_EVT_WND_CONFIG_CHANGED,
 82	FTK_EVT_TAB_PAGE_ACTIVATE,
 83	FTK_EVT_TAB_PAGE_DEACTIVATE
 84}FtkEventType;
 85
 86typedef struct _FtkEvent
 87{
 88	FtkEventType type;
 89
 90	void* widget;
 91	size_t time;
 92	union
 93	{
 94		struct _Idle
 95		{
 96			FtkIdle action;
 97			void* user_data;
 98		}idle;
 99		struct _Timer
100		{
101			FtkTimer action;
102			int interval;
103			void* user_data;
104		}timer;
105		struct _Key
106		{
107			int code;
108		}key;
109		struct _Mouse
110		{
111			unsigned char press;
112			unsigned char button;
113			unsigned short x;
114			unsigned short y;
115		}mouse;
116		
117		struct _Display
118		{
119			void* display;
120			int width;
121			int height;
122		}display;
123		FtkRect rect;
124		void* extra;
125	}u;
126}FtkEvent;
127
128typedef Ret (*FtkOnEvent)(void* user_data, FtkEvent* event);
129
130static inline Ret ftk_event_init(FtkEvent* event, FtkEventType type)
131{
132	if(event != NULL)
133	{
134		memset(event, 0x00, sizeof(FtkEvent));
135		event->type = type;
136	}
137
138	return RET_OK;
139}
140
141FTK_END_DECLS
142
143#endif/*FTK_EVENT_H*/