PageRenderTime 405ms CodeModel.GetById 222ms app.highlight 13ms RepoModel.GetById 168ms app.codeStats 0ms

/src/ftk_wnd_manager.h

http://ftk.googlecode.com/
C++ Header | 166 lines | 100 code | 37 blank | 29 comment | 38 complexity | 5e68568481da477e9859332b9440d32d MD5 | raw file
  1/*
  2 * File: ftk_wnd_manager.h    
  3 * Author:  Li XianJing <xianjimli@hotmail.com>
  4 * Brief:   window manager interface.
  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
 32#ifndef FTK_WND_MANAGER_H
 33#define FTK_WND_MANAGER_H
 34
 35#include "ftk_widget.h"
 36#include "ftk_main_loop.h"
 37
 38FTK_BEGIN_DECLS
 39
 40struct _FtkWndManager;
 41typedef struct _FtkWndManager FtkWndManager;
 42
 43typedef Ret  (*FtkWndManagerRestack)(FtkWndManager* thiz, FtkWidget* window, int offset);
 44typedef Ret  (*FtkWndManagerGrab)(FtkWndManager* thiz, FtkWidget* window);
 45typedef Ret  (*FtkWndManagerUngrab)(FtkWndManager* thiz, FtkWidget* window);
 46typedef Ret  (*FtkWndManagerAdd)(FtkWndManager* thiz, FtkWidget* window);
 47typedef Ret  (*FtkWndManagerRemove)(FtkWndManager* thiz, FtkWidget* window);
 48typedef Ret  (*FtkWndManagerUpdate)(FtkWndManager* thiz);
 49typedef Ret  (*FtkWndManagerGetWorkArea)(FtkWndManager* thiz, FtkRect* rect);
 50typedef Ret  (*FtkWndManagerQueueEvent)(FtkWndManager* thiz, FtkEvent* event);
 51typedef Ret  (*FtkWndManagerDispatchEvent)(FtkWndManager* thiz, FtkEvent* event);
 52typedef Ret  (*FtkWndManagerAddGlobalListener)(FtkWndManager* thiz, FtkListener listener, void* ctx);
 53typedef Ret  (*FtkWndManagerRemoveGlobalListener)(FtkWndManager* thiz, FtkListener listener, void* ctx);
 54typedef void (*FtkWndManagerDestroy)(FtkWndManager* thiz);
 55
 56struct _FtkWndManager
 57{
 58	FtkWndManagerGrab                 grab;
 59	FtkWndManagerUngrab               ungrab;
 60	FtkWndManagerAdd                  add;
 61	FtkWndManagerRemove               remove;
 62	FtkWndManagerUpdate               update;
 63	FtkWndManagerRestack              restack;
 64	FtkWndManagerGetWorkArea          get_work_area;
 65	FtkWndManagerQueueEvent           queue_event;
 66	FtkWndManagerDispatchEvent        dispatch_event;
 67	FtkWndManagerAddGlobalListener    add_global_listener;
 68	FtkWndManagerRemoveGlobalListener remove_global_listener;
 69	FtkWndManagerDestroy              destroy;
 70
 71	char priv[ZERO_LEN_ARRAY];
 72};
 73
 74static inline Ret  ftk_wnd_manager_restack(FtkWndManager* thiz, FtkWidget* window, int offset)
 75{
 76	return_val_if_fail(thiz != NULL && thiz->restack != NULL, RET_FAIL);
 77
 78	return thiz->restack(thiz, window, offset);
 79}
 80
 81static inline Ret  ftk_wnd_manager_grab(FtkWndManager* thiz, FtkWidget* window)
 82{
 83	return_val_if_fail(thiz != NULL && thiz->grab != NULL, RET_FAIL);
 84
 85	return thiz->grab(thiz, window);
 86}
 87
 88static inline Ret  ftk_wnd_manager_ungrab(FtkWndManager* thiz, FtkWidget* window)
 89{
 90	return_val_if_fail(thiz != NULL && thiz->ungrab != NULL, RET_FAIL);
 91
 92	return thiz->ungrab(thiz, window);
 93}
 94
 95static inline Ret  ftk_wnd_manager_add(FtkWndManager* thiz, FtkWidget* window)
 96{
 97	return_val_if_fail(thiz != NULL && thiz->add != NULL, RET_FAIL);
 98
 99	return thiz->add(thiz, window);
100}
101
102static inline Ret  ftk_wnd_manager_remove(FtkWndManager* thiz, FtkWidget* window)
103{
104	return_val_if_fail(thiz != NULL && thiz->remove != NULL, RET_FAIL);
105
106	return thiz->remove(thiz, window);
107}
108
109static inline Ret  ftk_wnd_manager_update(FtkWndManager* thiz)
110{
111	return_val_if_fail(thiz != NULL && thiz->update != NULL, RET_FAIL);
112
113	return thiz->update(thiz);
114}
115
116static inline Ret  ftk_wnd_manager_get_work_area(FtkWndManager* thiz, FtkRect* rect)
117{
118	return_val_if_fail(thiz != NULL && thiz->get_work_area != NULL && rect != NULL, RET_FAIL);
119
120	return thiz->get_work_area(thiz, rect);
121}
122
123static inline Ret  ftk_wnd_manager_queue_event(FtkWndManager* thiz, FtkEvent* event)
124{
125	return_val_if_fail(thiz != NULL && thiz->queue_event != NULL, RET_FAIL);
126
127	return thiz->queue_event(thiz, event);
128}
129
130static inline Ret  ftk_wnd_manager_dispatch_event(FtkWndManager* thiz, FtkEvent* event)
131{
132	return_val_if_fail(thiz != NULL && thiz->dispatch_event != NULL, RET_FAIL);
133
134	return thiz->dispatch_event(thiz, event);
135}
136
137static inline Ret  ftk_wnd_manager_add_global_listener(FtkWndManager* thiz, FtkListener listener, void* ctx)
138{
139	return_val_if_fail(thiz != NULL && thiz->add_global_listener != NULL, RET_FAIL);
140
141	return thiz->add_global_listener(thiz, listener, ctx);
142}
143
144static inline Ret  ftk_wnd_manager_remove_global_listener(FtkWndManager* thiz, FtkListener listener, void* ctx)
145{
146	return_val_if_fail(thiz != NULL && thiz->remove_global_listener != NULL, RET_FAIL);
147
148	return thiz->remove_global_listener(thiz, listener, ctx);
149}
150
151static inline void ftk_wnd_manager_destroy(FtkWndManager* thiz)
152{
153	return_if_fail(thiz != NULL && thiz->destroy != NULL);
154
155	thiz->destroy(thiz);
156
157	return;
158}
159
160Ret  ftk_wnd_manager_set_rotate(FtkWndManager* thiz, FtkRotate rotate);
161Ret  ftk_wnd_manager_queue_event_auto_rotate(FtkWndManager* thiz, FtkEvent* event);
162
163FTK_END_DECLS
164
165#endif/*FTK_WND_MANAGER_H*/
166