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 struct wmWindow *WM_window_open (struct bContext *C, struct rcti *rect);
57 /* defines for 'type' WM_window_open_temp */
58 #define WM_WINDOW_RENDER 0
59 #define WM_WINDOW_USERPREFS 1
60 #define WM_WINDOW_FILESEL 2
62 void WM_window_open_temp (struct bContext *C, struct rcti *position, int type);
67 int WM_read_homefile (struct bContext *C, struct wmOperator *op);
68 int WM_write_homefile (struct bContext *C, struct wmOperator *op);
69 void WM_read_file (struct bContext *C, char *name, struct ReportList *reports);
70 void WM_write_file (struct bContext *C, char *target, int compress, struct ReportList *reports);
71 void WM_read_autosavefile(struct bContext *C);
72 void WM_write_autosave (struct bContext *C);
75 void WM_cursor_set (struct wmWindow *win, int curs);
76 void WM_cursor_modal (struct wmWindow *win, int curs);
77 void WM_cursor_restore (struct wmWindow *win);
78 void WM_cursor_wait (int val);
79 void WM_cursor_grab(struct wmWindow *win, int warp);
80 void WM_cursor_ungrab(wmWindow *win, int restore);
81 void WM_timecursor (struct wmWindow *win, int nr);
83 void *WM_paint_cursor_activate(struct wmWindowManager *wm, int (*poll)(struct bContext *C), void (*draw)(struct bContext *C, int, int, void *customdata), void *customdata);
84 void WM_paint_cursor_end(struct wmWindowManager *wm, void *handle);
86 /* keyconfig and keymap */
87 wmKeyConfig *WM_keyconfig_add (struct wmWindowManager *wm, char *idname);
88 void WM_keyconfig_free (struct wmKeyConfig *keyconf);
89 void WM_keyconfig_userdef(struct wmWindowManager *wm);
91 void WM_keymap_init (struct bContext *C);
92 void WM_keymap_free (struct wmKeyMap *keymap);
94 wmKeyMapItem *WM_keymap_verify_item(struct wmKeyMap *keymap, char *idname, int type,
95 int val, int modifier, int keymodifier);
96 wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, char *idname, int type,
97 int val, int modifier, int keymodifier);
98 void WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
99 char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len);
101 wmKeyMap *WM_keymap_find(struct wmKeyConfig *keyconf, char *idname, int spaceid, int regionid);
102 wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap);
103 wmKeyMap *WM_keymap_copy_to_user(struct wmKeyMap *keymap);
104 void WM_keymap_restore_to_default(struct wmKeyMap *keymap);
106 wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, char *idname, struct EnumPropertyItem *items);
107 wmKeyMap *WM_modalkeymap_get(struct wmKeyConfig *keyconf, char *idname);
108 void WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value);
109 void WM_modalkeymap_assign(struct wmKeyMap *km, char *opname);
111 const char *WM_key_event_string(short type);
112 char *WM_key_event_operator_string(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, char *str, int len);
113 void WM_key_event_operator_change(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, short key, short modifier);
117 struct wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
118 /* boundbox, optional subwindow boundbox for offset */
119 struct wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, wmKeyMap *keymap, rcti *bb, rcti *swinbb);
120 /* priority not implemented, it adds in begin */
121 struct wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, wmKeyMap *keymap, int priority);
123 void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
125 struct wmEventHandler *WM_event_add_ui_handler(const struct bContext *C, ListBase *handlers,
126 int (*func)(struct bContext *C, struct wmEvent *event, void *userdata),
127 void (*remove)(struct bContext *C, void *userdata), void *userdata);
128 void WM_event_remove_ui_handler(ListBase *handlers,
129 int (*func)(struct bContext *C, struct wmEvent *event, void *userdata),
130 void (*remove)(struct bContext *C, void *userdata), void *userdata);
132 struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op);
133 void WM_event_remove_handlers(struct bContext *C, ListBase *handlers);
135 void WM_event_add_mousemove(struct bContext *C);
136 int WM_modal_tweak_exit(struct wmEvent *evt, int tweak_event);
138 void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference);
139 void WM_main_add_notifier(unsigned int type, void *reference);
141 void wm_event_add (struct wmWindow *win, struct wmEvent *event_to_add); /* XXX only for warning */
143 /* at maximum, every timestep seconds it triggers event_type events */
144 struct wmTimer *WM_event_add_window_timer(struct wmWindow *win, int event_type, double timestep);
145 void WM_event_remove_window_timer(struct wmWindow *win, struct wmTimer *timer);
146 void WM_event_window_timer_sleep(struct wmWindow *win, struct wmTimer *timer, int dosleep);
148 /* operator api, default callbacks */
149 /* invoke callback, uses enum property named "type" */
150 int WM_menu_invoke (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
151 /* invoke callback, confirm menu + exec */
152 int WM_operator_confirm (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
153 /* invoke callback, file selector "path" unset + exec */
154 int WM_operator_filesel (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
155 /* poll callback, context checks */
156 int WM_operator_winactive (struct bContext *C);
157 /* invoke callback, exec + redo popup */
158 int WM_operator_props_popup (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
159 int WM_operator_redo_popup (struct bContext *C, struct wmOperator *op);
161 int WM_operator_confirm_message(struct bContext *C, struct wmOperator *op, char *message);
164 void WM_operator_free (struct wmOperator *op);
165 void WM_operator_stack_clear(struct bContext *C);
167 wmOperatorType *WM_operatortype_find(const char *idnamem, int quiet);
168 wmOperatorType *WM_operatortype_exists(const char *idname);
169 wmOperatorType *WM_operatortype_first(void);
170 void WM_operatortype_append (void (*opfunc)(wmOperatorType*));
171 void WM_operatortype_append_ptr (void (*opfunc)(wmOperatorType*, void *), void *userdata);
172 int WM_operatortype_remove(const char *idname);
174 wmOperatorType *WM_operatortype_append_macro(char *idname, char *name, int flag);
175 wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char *idname);
178 int WM_operator_poll (struct bContext *C, struct wmOperatorType *ot);
179 int WM_operator_call (struct bContext *C, struct wmOperator *op);
180 int WM_operator_repeat (struct bContext *C, struct wmOperator *op);
181 int WM_operator_name_call (struct bContext *C, const char *opstring, int context, struct PointerRNA *properties);
182 int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, int context, struct PointerRNA *properties, struct ReportList *reports);
184 void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring);
185 void WM_operator_properties_free(struct PointerRNA *ptr);
186 void WM_operator_properties_filesel(struct wmOperatorType *ot, int filter, short type);
188 /* operator as a python command (resultuing string must be free'd) */
189 char *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args);
190 void WM_operator_bl_idname(char *to, const char *from);
191 void WM_operator_py_idname(char *to, const char *from);
193 /* *************** menu types ******************** */
194 struct MenuType *WM_menutype_find(const char *idname, int quiet);
195 int WM_menutype_add(struct MenuType* mt);
196 void WM_menutype_freelink(struct MenuType* mt);
197 void WM_menutype_free(void);
199 /* default operator callbacks for border/circle/lasso */
200 int WM_border_select_invoke (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
201 int WM_border_select_modal (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
202 int WM_gesture_circle_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
203 int WM_gesture_circle_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
204 int WM_gesture_lines_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
205 int WM_gesture_lines_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
206 int WM_gesture_lasso_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
207 int WM_gesture_lasso_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
209 /* default operator for arearegions, generates event */
210 void WM_OT_tweak_gesture(struct wmOperatorType *ot);
212 /* Gesture manager API */
213 struct wmGesture *WM_gesture_new(struct bContext *C, struct wmEvent *event, int type);
214 void WM_gesture_end(struct bContext *C, struct wmGesture *gesture);
216 /* radial control operator */
217 int WM_radial_control_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
218 int WM_radial_control_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
219 void WM_OT_radial_control_partial(struct wmOperatorType *ot);
220 void WM_radial_control_string(struct wmOperator *op, char str[], int maxlen);
222 /* fileselecting support */
223 void WM_event_add_fileselect(struct bContext *C, struct wmOperator *op);
224 void WM_event_fileselect_event(struct bContext *C, void *ophandle, int eventval);
226 /* OpenGL wrappers, mimicking opengl syntax */
227 void wmSubWindowSet (struct wmWindow *win, int swinid);
228 void wmSubWindowScissorSet (struct wmWindow *win, int swinid, struct rcti *srct);
230 void wmLoadMatrix (float mat[][4]);
231 void wmGetMatrix (float mat[][4]);
232 void wmMultMatrix (float mat[][4]);
233 void wmGetSingleMatrix (float mat[][4]);
234 void wmScale (float x, float y, float z);
235 void wmLoadIdentity (void); /* note: old name clear_view_mat */
236 void wmPushMatrix (void); /* one level only */
237 void wmPopMatrix (void); /* one level only */
239 void wmFrustum (float x1, float x2, float y1, float y2, float n, float f);
240 void wmOrtho (float x1, float x2, float y1, float y2, float n, float f);
241 void wmOrtho2 (float x1, float x2, float y1, float y2);
244 void WM_set_framebuffer_index_color(int index);
245 int WM_framebuffer_to_index(unsigned int col);
247 /* threaded Jobs Manager */
248 #define WM_JOB_PRIORITY 1
249 #define WM_JOB_EXCL_RENDER 2
251 struct wmJob *WM_jobs_get(struct wmWindowManager *wm, struct wmWindow *win, void *owner, int flag);
253 int WM_jobs_test(struct wmWindowManager *wm, void *owner);
255 void WM_jobs_customdata(struct wmJob *, void *customdata, void (*free)(void *));
256 void WM_jobs_timer(struct wmJob *, double timestep, unsigned int note, unsigned int endnote);
257 void WM_jobs_callbacks(struct wmJob *,
258 void (*startjob)(void *, short *, short *),
259 void (*initjob)(void *),
260 void (*update)(void *));
262 void WM_jobs_start(struct wmWindowManager *wm, struct wmJob *);
263 void WM_jobs_stop(struct wmWindowManager *wm, void *owner);
264 void WM_jobs_stop_all(struct wmWindowManager *wm);
267 char *WM_clipboard_text_get(int selection);
268 void WM_clipboard_text_set(char *buf, int selection);
270 #endif /* WM_API_H */