remove unused includes from editors/space_*
[blender.git] / source / blender / editors / space_text / text_header.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
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. 
10  *
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.
15  *
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * The Original Code is Copyright (C) 2008 Blender Foundation.
21  * All rights reserved.
22  *
23  * 
24  * Contributor(s): Blender Foundation
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #include <stdlib.h>
30 #include <string.h>
31 #include <stdio.h>
32
33 /* file time checking */
34 #include <ctype.h>
35 #include <sys/types.h>
36 #include <sys/stat.h>
37
38 #ifndef _WIN32
39 #include <unistd.h>
40 #else
41 #include <io.h>
42 #include "BLI_winstuff.h"
43 #endif
44
45 #include "DNA_windowmanager_types.h"
46
47 #include "MEM_guardedalloc.h"
48
49 #include "BLI_blenlib.h"
50
51 #include "BKE_context.h"
52
53 #include "ED_screen.h"
54
55 #include "WM_types.h"
56
57 #include "BIF_gl.h"
58 #include "BIF_glutil.h"
59
60
61
62 #ifndef DISABLE_PYTHON
63 #include "BPY_extern.h"
64 // XXX #include "BPY_menus.h"
65 #endif
66
67 #include "text_intern.h"
68
69 #define HEADER_PATH_MAX 260
70
71 /* ************************ header area region *********************** */
72
73 /************************** properties ******************************/
74
75 ARegion *text_has_properties_region(ScrArea *sa)
76 {
77         ARegion *ar, *arnew;
78         
79         for(ar= sa->regionbase.first; ar; ar= ar->next)
80                 if(ar->regiontype==RGN_TYPE_UI)
81                         return ar;
82         
83         /* add subdiv level; after header */
84         for(ar= sa->regionbase.first; ar; ar= ar->next)
85                 if(ar->regiontype==RGN_TYPE_HEADER)
86                         break;
87         
88         /* is error! */
89         if(ar==NULL) return NULL;
90         
91         arnew= MEM_callocN(sizeof(ARegion), "properties region");
92         
93         BLI_insertlinkafter(&sa->regionbase, ar, arnew);
94         arnew->regiontype= RGN_TYPE_UI;
95         arnew->alignment= RGN_ALIGN_LEFT;
96         
97         arnew->flag = RGN_FLAG_HIDDEN;
98         
99         return arnew;
100 }
101
102 static int properties_poll(bContext *C)
103 {
104         return (CTX_wm_space_text(C) != NULL);
105 }
106
107 static int properties_exec(bContext *C, wmOperator *op)
108 {
109         ScrArea *sa= CTX_wm_area(C);
110         ARegion *ar= text_has_properties_region(sa);
111         
112         if(ar)
113                 ED_region_toggle_hidden(C, ar);
114
115         return OPERATOR_FINISHED;
116 }
117
118 void TEXT_OT_properties(wmOperatorType *ot)
119 {
120         /* identifiers */
121         ot->name= "Properties";
122         ot->description= "Toggle text properties panel";
123         ot->idname= "TEXT_OT_properties";
124         
125         /* api callbacks */
126         ot->exec= properties_exec;
127         ot->poll= properties_poll;
128 }
129
130 /******************** XXX popup menus *******************/
131
132 #if 0
133 {
134         // RMB
135
136         uiPopupMenu *pup;
137
138         if(text) {
139                 pup= uiPupMenuBegin(C, "Text", 0);
140                 if(txt_has_sel(text)) {
141                         uiItemO(layout, NULL, 0, "TEXT_OT_cut");
142                         uiItemO(layout, NULL, 0, "TEXT_OT_copy");
143                 }
144                 uiItemO(layout, NULL, 0, "TEXT_OT_paste");
145                 uiItemO(layout, NULL, 0, "TEXT_OT_new");
146                 uiItemO(layout, NULL, 0, "TEXT_OT_open");
147                 uiItemO(layout, NULL, 0, "TEXT_OT_save");
148                 uiItemO(layout, NULL, 0, "TEXT_OT_save_as");
149                 uiItemO(layout, NULL, 0, "TEXT_OT_run_script");
150                 uiPupMenuEnd(C, pup);
151         }
152         else {
153                 pup= uiPupMenuBegin(C, "File", 0);
154                 uiItemO(layout, NULL, 0, "TEXT_OT_new");
155                 uiItemO(layout, NULL, 0, "TEXT_OT_open");
156                 uiPupMenuEnd(C, pup);
157         }
158 }
159
160 {
161         // Alt+Shift+E
162
163         uiPopupMenu *pup;
164
165         pup= uiPupMenuBegin(C, "Edit", 0);
166         uiItemO(layout, NULL, 0, "TEXT_OT_cut");
167         uiItemO(layout, NULL, 0, "TEXT_OT_copy");
168         uiItemO(layout, NULL, 0, "TEXT_OT_paste");
169         uiPupMenuEnd(C, pup);
170 }
171
172 {
173         // Alt+Shift+F
174
175         uiPopupMenu *pup;
176
177         if(text) {
178                 pup= uiPupMenuBegin(C, "Text", 0);
179                 uiItemO(layout, NULL, 0, "TEXT_OT_new");
180                 uiItemO(layout, NULL, 0, "TEXT_OT_open");
181                 uiItemO(layout, NULL, 0, "TEXT_OT_save");
182                 uiItemO(layout, NULL, 0, "TEXT_OT_save_as");
183                 uiItemO(layout, NULL, 0, "TEXT_OT_run_script");
184                 uiPupMenuEnd(C, pup);
185         }
186         else {
187                 pup= uiPupMenuBegin(C, "File", 0);
188                 uiItemO(layout, NULL, 0, "TEXT_OT_new");
189                 uiItemO(layout, NULL, 0, "TEXT_OT_open");
190                 uiPupMenuEnd(C, pup);
191         }
192 }
193
194 {
195         // Alt+Shift+V
196
197         uiPopupMenu *pup;
198
199         pup= uiPupMenuBegin(C, "Text", 0);
200         uiItemEnumO(layout, "TEXT_OT_move", "Top of File", 0, "type", FILE_TOP);
201         uiItemEnumO(layout, "TEXT_OT_move", "Bottom of File", 0, "type", FILE_BOTTOM);
202         uiItemEnumO(layout, "TEXT_OT_move", "Page Up", 0, "type", PREV_PAGE);
203         uiItemEnumO(layout, "TEXT_OT_move", "Page Down", 0, "type", NEXT_PAGE);
204         uiPupMenuEnd(C, pup);
205 }
206 #endif
207