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) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * Contributor(s): Blender Foundation (2008).
25 * ***** END GPL LICENSE BLOCK *****
35 #include "DNA_listBase.h"
36 #include "RNA_types.h"
59 struct wmWindowManager;
67 typedef struct bContext bContext;
69 struct bContextDataResult;
70 typedef struct bContextDataResult bContextDataResult;
72 typedef int (*bContextDataCallback)(const bContext *C,
73 const char *member, bContextDataResult *result);
75 typedef struct bContextStoreEntry {
76 struct bContextStoreEntry *next, *prev;
82 typedef struct bContextStore {
83 struct bContextStore *next, *prev;
91 bContext *CTX_create(void);
92 void CTX_free(bContext *C);
94 bContext *CTX_copy(const bContext *C);
98 bContextStore *CTX_store_add(ListBase *contexts, char *name, PointerRNA *ptr);
99 void CTX_store_set(bContext *C, bContextStore *store);
100 bContextStore *CTX_store_copy(bContextStore *store);
101 void CTX_store_free(bContextStore *store);
102 void CTX_store_free_list(ListBase *contexts);
104 /* Window Manager Context */
106 struct wmWindowManager *CTX_wm_manager(const bContext *C);
107 struct wmWindow *CTX_wm_window(const bContext *C);
108 struct bScreen *CTX_wm_screen(const bContext *C);
109 struct ScrArea *CTX_wm_area(const bContext *C);
110 struct SpaceLink *CTX_wm_space_data(const bContext *C);
111 struct ARegion *CTX_wm_region(const bContext *C);
112 void *CTX_wm_region_data(const bContext *C);
113 struct ARegion *CTX_wm_menu(const bContext *C);
115 struct View3D *CTX_wm_view3d(const bContext *C);
116 struct RegionView3D *CTX_wm_region_view3d(const bContext *C);
117 struct SpaceText *CTX_wm_space_text(const bContext *C);
118 struct SpaceImage *CTX_wm_space_image(const bContext *C);
120 void CTX_wm_manager_set(bContext *C, struct wmWindowManager *wm);
121 void CTX_wm_window_set(bContext *C, struct wmWindow *win);
122 void CTX_wm_screen_set(bContext *C, struct bScreen *screen); /* to be removed */
123 void CTX_wm_area_set(bContext *C, struct ScrArea *sa);
124 void CTX_wm_region_set(bContext *C, struct ARegion *region);
125 void CTX_wm_menu_set(bContext *C, struct ARegion *menu);
129 - listbases consist of CollectionPointerLink items and must be
130 freed with BLI_freelistN!
131 - the dir listbase consits of LinkData items */
133 PointerRNA CTX_data_pointer_get(const bContext *C, const char *member);
134 PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type);
135 ListBase CTX_data_collection_get(const bContext *C, const char *member);
136 ListBase CTX_data_dir_get(const bContext *C);
137 void CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb);
139 void CTX_data_id_pointer_set(bContextDataResult *result, struct ID *id);
140 void CTX_data_pointer_set(bContextDataResult *result, struct ID *id, StructRNA *type, void *data);
142 void CTX_data_id_list_add(bContextDataResult *result, struct ID *id);
143 void CTX_data_list_add(bContextDataResult *result, struct ID *id, StructRNA *type, void *data);
145 void CTX_data_dir_set(bContextDataResult *result, const char **member);
147 int CTX_data_equals(const char *member, const char *str);
148 int CTX_data_dir(const char *member);
150 /*void CTX_data_pointer_set(bContextDataResult *result, void *data);
151 void CTX_data_list_add(bContextDataResult *result, void *data);*/
153 #define CTX_DATA_BEGIN(C, Type, instance, member) \
155 ListBase ctx_data_list; \
156 CollectionPointerLink *ctx_link; \
157 CTX_data_##member(C, &ctx_data_list); \
158 for(ctx_link=ctx_data_list.first; ctx_link; ctx_link=ctx_link->next) { \
159 Type instance= ctx_link->ptr.data;
161 #define CTX_DATA_END \
163 BLI_freelistN(&ctx_data_list); \
166 int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase*));
168 #define CTX_DATA_COUNT(C, member) \
169 ctx_data_list_count(C, CTX_data_##member)
171 /* Data Context Members */
173 struct Main *CTX_data_main(const bContext *C);
174 struct Scene *CTX_data_scene(const bContext *C);
175 struct ToolSettings *CTX_data_tool_settings(const bContext *C);
177 void CTX_data_main_set(bContext *C, struct Main *bmain);
178 void CTX_data_scene_set(bContext *C, struct Scene *bmain);
180 int CTX_data_selected_editable_objects(const bContext *C, ListBase *list);
181 int CTX_data_selected_editable_bases(const bContext *C, ListBase *list);
183 int CTX_data_selected_objects(const bContext *C, ListBase *list);
184 int CTX_data_selected_bases(const bContext *C, ListBase *list);
186 int CTX_data_visible_objects(const bContext *C, ListBase *list);
187 int CTX_data_visible_bases(const bContext *C, ListBase *list);
189 struct Object *CTX_data_active_object(const bContext *C);
190 struct Base *CTX_data_active_base(const bContext *C);
191 struct Object *CTX_data_edit_object(const bContext *C);
193 struct Image *CTX_data_edit_image(const bContext *C);
195 struct Text *CTX_data_edit_text(const bContext *C);
197 int CTX_data_selected_nodes(const bContext *C, ListBase *list);
199 struct EditBone *CTX_data_active_bone(const bContext *C);
200 int CTX_data_selected_bones(const bContext *C, ListBase *list);
201 int CTX_data_selected_editable_bones(const bContext *C, ListBase *list);
202 int CTX_data_visible_bones(const bContext *C, ListBase *list);
203 int CTX_data_editable_bones(const bContext *C, ListBase *list);
205 struct bPoseChannel *CTX_data_active_pchan(const bContext *C);
206 int CTX_data_selected_pchans(const bContext *C, ListBase *list);
207 int CTX_data_visible_pchans(const bContext *C, ListBase *list);