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 * Contributor(s): Blender Foundation (2009).
22 * ***** END GPL LICENSE BLOCK *****
29 #include "RNA_access.h"
30 #include "RNA_define.h"
31 #include "RNA_types.h"
35 #include "BKE_context.h"
37 static PointerRNA rna_Context_manager_get(PointerRNA *ptr)
39 bContext *C= (bContext*)ptr->data;
40 return rna_pointer_inherit_refine(ptr, &RNA_WindowManager, CTX_wm_manager(C));
43 static PointerRNA rna_Context_window_get(PointerRNA *ptr)
45 bContext *C= (bContext*)ptr->data;
46 return rna_pointer_inherit_refine(ptr, &RNA_Window, CTX_wm_window(C));
49 static PointerRNA rna_Context_screen_get(PointerRNA *ptr)
51 bContext *C= (bContext*)ptr->data;
52 return rna_pointer_inherit_refine(ptr, &RNA_Screen, CTX_wm_screen(C));
55 static PointerRNA rna_Context_area_get(PointerRNA *ptr)
57 bContext *C= (bContext*)ptr->data;
59 RNA_pointer_create((ID*)CTX_wm_screen(C), &RNA_Area, CTX_wm_area(C), &newptr);
63 static PointerRNA rna_Context_space_data_get(PointerRNA *ptr)
65 bContext *C= (bContext*)ptr->data;
67 RNA_pointer_create((ID*)CTX_wm_screen(C), &RNA_Space, CTX_wm_space_data(C), &newptr);
71 static PointerRNA rna_Context_region_get(PointerRNA *ptr)
73 bContext *C= (bContext*)ptr->data;
75 RNA_pointer_create((ID*)CTX_wm_screen(C), &RNA_Region, CTX_wm_region(C), &newptr);
79 /*static PointerRNA rna_Context_region_data_get(PointerRNA *ptr)
81 bContext *C= (bContext*)ptr->data;
83 RNA_pointer_create((ID*)CTX_wm_screen(C), &RNA_RegionData, CTX_wm_region_data(C), &newptr);
87 static PointerRNA rna_Context_main_get(PointerRNA *ptr)
89 bContext *C= (bContext*)ptr->data;
90 return rna_pointer_inherit_refine(ptr, &RNA_Main, CTX_data_main(C));
93 static PointerRNA rna_Context_scene_get(PointerRNA *ptr)
95 bContext *C= (bContext*)ptr->data;
96 return rna_pointer_inherit_refine(ptr, &RNA_Scene, CTX_data_scene(C));
99 static PointerRNA rna_Context_tool_settings_get(PointerRNA *ptr)
101 bContext *C= (bContext*)ptr->data;
102 return rna_pointer_inherit_refine(ptr, &RNA_ToolSettings, CTX_data_tool_settings(C));
107 void RNA_def_context(BlenderRNA *brna)
112 srna= RNA_def_struct(brna, "Context", NULL);
113 RNA_def_struct_ui_text(srna, "Context", "Current windowmanager and data context.");
114 RNA_def_struct_sdna(srna, "bContext");
117 prop= RNA_def_property(srna, "manager", PROP_POINTER, PROP_NONE);
118 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
119 RNA_def_property_struct_type(prop, "WindowManager");
120 RNA_def_property_pointer_funcs(prop, "rna_Context_manager_get", NULL, NULL);
122 prop= RNA_def_property(srna, "window", PROP_POINTER, PROP_NONE);
123 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
124 RNA_def_property_struct_type(prop, "Window");
125 RNA_def_property_pointer_funcs(prop, "rna_Context_window_get", NULL, NULL);
127 prop= RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE);
128 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
129 RNA_def_property_struct_type(prop, "Screen");
130 RNA_def_property_pointer_funcs(prop, "rna_Context_screen_get", NULL, NULL);
132 prop= RNA_def_property(srna, "area", PROP_POINTER, PROP_NONE);
133 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
134 RNA_def_property_struct_type(prop, "Area");
135 RNA_def_property_pointer_funcs(prop, "rna_Context_area_get", NULL, NULL);
137 prop= RNA_def_property(srna, "space_data", PROP_POINTER, PROP_NONE);
138 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
139 RNA_def_property_struct_type(prop, "Space");
140 RNA_def_property_pointer_funcs(prop, "rna_Context_space_data_get", NULL, NULL);
142 prop= RNA_def_property(srna, "region", PROP_POINTER, PROP_NONE);
143 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
144 RNA_def_property_struct_type(prop, "Region");
145 RNA_def_property_pointer_funcs(prop, "rna_Context_region_get", NULL, NULL);
147 /*prop= RNA_def_property(srna, "region_data", PROP_POINTER, PROP_NONE);
148 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
149 RNA_def_property_struct_type(prop, "RegionData");
150 RNA_def_property_pointer_funcs(prop, "rna_Context_region_data_get", NULL, NULL);*/
153 prop= RNA_def_property(srna, "main", PROP_POINTER, PROP_NONE);
154 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
155 RNA_def_property_struct_type(prop, "Main");
156 RNA_def_property_pointer_funcs(prop, "rna_Context_main_get", NULL, NULL);
158 prop= RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
159 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
160 RNA_def_property_struct_type(prop, "Scene");
161 RNA_def_property_pointer_funcs(prop, "rna_Context_scene_get", NULL, NULL);
163 prop= RNA_def_property(srna, "tool_settings", PROP_POINTER, PROP_NONE);
164 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
165 RNA_def_property_struct_type(prop, "ToolSettings");
166 RNA_def_property_pointer_funcs(prop, "rna_Context_tool_settings_get", NULL, NULL);