4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2007 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation
26 * ***** END GPL LICENSE BLOCK *****
31 /* dna-savable wmStructs here */
32 #include "DNA_windowmanager_types.h"
37 struct wmEventHandler;
43 struct EnumPropertyItem;
46 typedef struct wmJob wmJob;
49 void WM_setprefsize (int stax, int stay, int sizx, int sizy);
51 void WM_init (struct bContext *C);
52 void WM_exit (struct bContext *C);
53 void WM_main (struct bContext *C);
55 void WM_init_splash (struct bContext *C);
58 void WM_check (struct bContext *C);
60 struct wmWindow *WM_window_open (struct bContext *C, struct rcti *rect);
62 /* defines for 'type' WM_window_open_temp */
63 #define WM_WINDOW_RENDER 0
64 #define WM_WINDOW_USERPREFS 1
65 #define WM_WINDOW_FILESEL 2
67 void WM_window_open_temp (struct bContext *C, struct rcti *position, int type);
72 int WM_read_homefile (struct bContext *C, struct wmOperator *op);
73 int WM_write_homefile (struct bContext *C, struct wmOperator *op);
74 void WM_read_file (struct bContext *C, char *name, struct ReportList *reports);
75 void WM_write_file (struct bContext *C, char *target, int fileflags, struct ReportList *reports);
76 void WM_read_autosavefile(struct bContext *C);
77 void WM_autosave_init (struct wmWindowManager *wm);
80 void WM_cursor_set (struct wmWindow *win, int curs);
81 void WM_cursor_modal (struct wmWindow *win, int curs);
82 void WM_cursor_restore (struct wmWindow *win);
83 void WM_cursor_wait (int val);
84 void WM_cursor_grab(struct wmWindow *win, int wrap, int hide, int *bounds);
85 void WM_cursor_ungrab(struct wmWindow *win);
86 void WM_timecursor (struct wmWindow *win, int nr);
88 void *WM_paint_cursor_activate(struct wmWindowManager *wm, int (*poll)(struct bContext *C), void (*draw)(struct bContext *C, int, int, void *customdata), void *customdata);
89 void WM_paint_cursor_end(struct wmWindowManager *wm, void *handle);
91 void WM_cursor_warp (struct wmWindow *win, int x, int y);
93 /* keyconfig and keymap */
94 wmKeyConfig *WM_keyconfig_add (struct wmWindowManager *wm, char *idname);
95 void WM_keyconfig_free (struct wmKeyConfig *keyconf);
96 void WM_keyconfig_userdef(struct wmWindowManager *wm);
98 void WM_keymap_init (struct bContext *C);
99 void WM_keymap_free (struct wmKeyMap *keymap);
101 wmKeyMapItem *WM_keymap_verify_item(struct wmKeyMap *keymap, char *idname, int type,
102 int val, int modifier, int keymodifier);
103 wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, char *idname, int type,
104 int val, int modifier, int keymodifier);
105 wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, char *idname, int type,
106 int val, int modifier, int keymodifier);
107 void WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
108 char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len);
110 wmKeyMap *WM_keymap_find(struct wmKeyConfig *keyconf, char *idname, int spaceid, int regionid);
111 wmKeyMap *WM_keymap_list_find(ListBase *lb, char *idname, int spaceid, int regionid);
112 wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap);
113 int WM_keymap_user_init(struct wmWindowManager *wm, struct wmKeyMap *keymap);
114 wmKeyMap *WM_keymap_copy_to_user(struct wmKeyMap *keymap);
115 void WM_keymap_restore_to_default(struct wmKeyMap *keymap);
116 void WM_keymap_properties_reset(struct wmKeyMapItem *kmi);
118 wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, char *idname, struct EnumPropertyItem *items);
119 wmKeyMap *WM_modalkeymap_get(struct wmKeyConfig *keyconf, char *idname);
120 wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value);
121 void WM_modalkeymap_assign(struct wmKeyMap *km, char *opname);
123 const char *WM_key_event_string(short type);
124 char *WM_key_event_operator_string(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, char *str, int len);
125 void WM_key_event_operator_change(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, short key, short modifier);
129 struct wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
130 /* boundbox, optional subwindow boundbox for offset */
131 struct wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, wmKeyMap *keymap, rcti *bb, rcti *swinbb);
132 /* priority not implemented, it adds in begin */
133 struct wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, wmKeyMap *keymap, int priority);
135 void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
137 struct wmEventHandler *WM_event_add_ui_handler(const struct bContext *C, ListBase *handlers,
138 int (*func)(struct bContext *C, struct wmEvent *event, void *userdata),
139 void (*remove)(struct bContext *C, void *userdata), void *userdata);
140 void WM_event_remove_ui_handler(ListBase *handlers,
141 int (*func)(struct bContext *C, struct wmEvent *event, void *userdata),
142 void (*remove)(struct bContext *C, void *userdata), void *userdata);
144 struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op);
145 void WM_event_remove_handlers(struct bContext *C, ListBase *handlers);
147 void WM_event_add_mousemove(struct bContext *C);
148 int WM_modal_tweak_exit(struct wmEvent *evt, int tweak_event);
150 void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference);
151 void WM_main_add_notifier(unsigned int type, void *reference);
153 void wm_event_add (struct wmWindow *win, struct wmEvent *event_to_add); /* XXX only for warning */
155 /* at maximum, every timestep seconds it triggers event_type events */
156 struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *win, int event_type, double timestep);
157 void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer);
158 void WM_event_timer_sleep(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer, int dosleep);
160 /* operator api, default callbacks */
161 /* invoke callback, uses enum property named "type" */
162 int WM_menu_invoke (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
163 /* invoke callback, confirm menu + exec */
164 int WM_operator_confirm (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
165 /* invoke callback, file selector "path" unset + exec */
166 int WM_operator_filesel (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
167 /* poll callback, context checks */
168 int WM_operator_winactive (struct bContext *C);
169 /* invoke callback, exec + redo popup */
170 int WM_operator_props_popup (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
171 int WM_operator_redo_popup (struct bContext *C, struct wmOperator *op);
172 void WM_operator_ui_popup (struct bContext *C, struct wmOperator *op, int width, int height);
174 int WM_operator_confirm_message(struct bContext *C, struct wmOperator *op, char *message);
177 void WM_operator_free (struct wmOperator *op);
178 void WM_operator_stack_clear(struct bContext *C);
180 wmOperatorType *WM_operatortype_find(const char *idnamem, int quiet);
181 wmOperatorType *WM_operatortype_exists(const char *idname);
182 wmOperatorType *WM_operatortype_first(void);
183 void WM_operatortype_append (void (*opfunc)(wmOperatorType*));
184 void WM_operatortype_append_ptr (void (*opfunc)(wmOperatorType*, void *), void *userdata);
185 void WM_operatortype_append_macro_ptr (void (*opfunc)(wmOperatorType*, void *), void *userdata);
186 int WM_operatortype_remove(const char *idname);
188 wmOperatorType *WM_operatortype_append_macro(char *idname, char *name, int flag);
189 wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char *idname);
192 int WM_operator_poll (struct bContext *C, struct wmOperatorType *ot);
193 int WM_operator_call (struct bContext *C, struct wmOperator *op);
194 int WM_operator_repeat (struct bContext *C, struct wmOperator *op);
195 int WM_operator_name_call (struct bContext *C, const char *opstring, int context, struct PointerRNA *properties);
196 int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, int context, struct PointerRNA *properties, struct ReportList *reports);
198 void WM_operator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *opstring); /* used for keymap and macro items */
199 void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring);
200 void WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot);
201 void WM_operator_properties_free(struct PointerRNA *ptr);
202 void WM_operator_properties_filesel(struct wmOperatorType *ot, int filter, short type);
203 void WM_operator_properties_gesture_border(wmOperatorType *ot, int extend);
204 void WM_operator_properties_select_all(wmOperatorType *ot);
206 /* MOVE THIS SOMEWHERE ELSE */
209 #define SEL_DESELECT 2
212 /* operator as a python command (resultuing string must be free'd) */
213 char *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args);
214 void WM_operator_bl_idname(char *to, const char *from);
215 void WM_operator_py_idname(char *to, const char *from);
217 /* *************** menu types ******************** */
218 struct MenuType *WM_menutype_find(const char *idname, int quiet);
219 int WM_menutype_add(struct MenuType* mt);
220 void WM_menutype_freelink(struct MenuType* mt);
221 void WM_menutype_free(void);
223 /* default operator callbacks for border/circle/lasso */
224 int WM_border_select_invoke (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
225 int WM_border_select_modal (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
226 int WM_gesture_circle_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
227 int WM_gesture_circle_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
228 int WM_gesture_lines_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
229 int WM_gesture_lines_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
230 int WM_gesture_lasso_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
231 int WM_gesture_lasso_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
233 /* default operator for arearegions, generates event */
234 void WM_OT_tweak_gesture(struct wmOperatorType *ot);
236 /* Gesture manager API */
237 struct wmGesture *WM_gesture_new(struct bContext *C, struct wmEvent *event, int type);
238 void WM_gesture_end(struct bContext *C, struct wmGesture *gesture);
240 /* radial control operator */
241 int WM_radial_control_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
242 int WM_radial_control_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
243 void WM_OT_radial_control_partial(struct wmOperatorType *ot);
244 void WM_radial_control_string(struct wmOperator *op, char str[], int maxlen);
246 /* fileselecting support */
247 void WM_event_add_fileselect(struct bContext *C, struct wmOperator *op);
248 void WM_event_fileselect_event(struct bContext *C, void *ophandle, int eventval);
250 /* OpenGL wrappers, mimicking opengl syntax */
251 void wmSubWindowSet (struct wmWindow *win, int swinid);
252 void wmSubWindowScissorSet (struct wmWindow *win, int swinid, struct rcti *srct);
254 void wmLoadMatrix (float mat[][4]);
255 void wmGetMatrix (float mat[][4]);
256 void wmMultMatrix (float mat[][4]);
257 void wmGetSingleMatrix (float mat[][4]);
258 void wmScale (float x, float y, float z);
259 void wmLoadIdentity (void); /* note: old name clear_view_mat */
260 void wmPushMatrix (void); /* one level only */
261 void wmPopMatrix (void); /* one level only */
263 void wmFrustum (float x1, float x2, float y1, float y2, float n, float f);
264 void wmOrtho (float x1, float x2, float y1, float y2, float n, float f);
265 void wmOrtho2 (float x1, float x2, float y1, float y2);
268 void WM_set_framebuffer_index_color(int index);
269 int WM_framebuffer_to_index(unsigned int col);
271 /* threaded Jobs Manager */
272 #define WM_JOB_PRIORITY 1
273 #define WM_JOB_EXCL_RENDER 2
275 struct wmJob *WM_jobs_get(struct wmWindowManager *wm, struct wmWindow *win, void *owner, int flag);
277 int WM_jobs_test(struct wmWindowManager *wm, void *owner);
279 void WM_jobs_customdata(struct wmJob *, void *customdata, void (*free)(void *));
280 void WM_jobs_timer(struct wmJob *, double timestep, unsigned int note, unsigned int endnote);
281 void WM_jobs_callbacks(struct wmJob *,
282 void (*startjob)(void *, short *, short *),
283 void (*initjob)(void *),
284 void (*update)(void *));
286 void WM_jobs_start(struct wmWindowManager *wm, struct wmJob *);
287 void WM_jobs_stop(struct wmWindowManager *wm, void *owner);
288 void WM_jobs_stop_all(struct wmWindowManager *wm);
291 char *WM_clipboard_text_get(int selection);
292 void WM_clipboard_text_set(char *buf, int selection);
294 #endif /* WM_API_H */