bf7b76cc7f822e2dd6b947ab36dd44b97bd43d6c
[blender.git] / source / blender / editors / screen / area.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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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 <string.h>
30 #include <stdio.h>
31
32 #include "MEM_guardedalloc.h"
33
34 #include "BLI_blenlib.h"
35 #include "BLI_arithb.h"
36 #include "BLI_rand.h"
37
38 #include "BKE_context.h"
39 #include "BKE_global.h"
40 #include "BKE_screen.h"
41 #include "BKE_utildefines.h"
42
43 #include "WM_api.h"
44 #include "WM_types.h"
45 #include "wm_subwindow.h"
46
47 #include "ED_screen.h"
48 #include "ED_screen_types.h"
49 #include "ED_types.h"
50
51 #include "BIF_gl.h"
52 #include "BIF_glutil.h"
53
54 #include "UI_interface.h"
55 #include "UI_resources.h"
56 #include "UI_view2d.h"
57
58 #include "BMF_Api.h"
59
60 #ifndef DISABLE_PYTHON
61 #include "BPY_extern.h"
62 #endif
63
64 #include "screen_intern.h"
65
66 /* general area and region code */
67
68 static void region_draw_emboss(ARegion *ar)
69 {
70         short winx, winy;
71         
72         winx= ar->winrct.xmax-ar->winrct.xmin;
73         winy= ar->winrct.ymax-ar->winrct.ymin;
74         
75         /* set transp line */
76         glEnable( GL_BLEND );
77         glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
78         
79         /* right  */
80         glColor4ub(0,0,0, 50);
81         sdrawline(winx, 0, winx, winy);
82         
83         /* bottom  */
84         glColor4ub(0,0,0, 80);
85         sdrawline(0, 0, winx, 0);
86         
87         /* top  */
88         glColor4ub(255,255,255, 60);
89         sdrawline(0, winy, winx, winy);
90
91         /* left  */
92         glColor4ub(255,255,255, 50);
93         sdrawline(0, 0, 0, winy);
94         
95         glDisable( GL_BLEND );
96 }
97
98 void ED_region_pixelspace(ARegion *ar)
99 {
100         int width= ar->winrct.xmax-ar->winrct.xmin+1;
101         int height= ar->winrct.ymax-ar->winrct.ymin+1;
102         
103         wmOrtho2(-0.375, (float)width-0.375, -0.375, (float)height-0.375);
104         wmLoadIdentity();
105 }
106
107 void ED_region_do_listen(ARegion *ar, wmNotifier *note)
108 {
109         /* generic notes first */
110         switch(note->category) {
111                 case NC_WINDOW:
112                         ED_region_tag_redraw(ar);
113                         break;
114                 case NC_SCREEN:
115                         if(note->action==NA_EDITED)
116                                 ED_region_tag_redraw(ar);
117                         break;
118                 default:
119                         if(ar->type && ar->type->listener)
120                                 ar->type->listener(ar, note);
121         }
122 }
123
124 /* based on screen region draw tags, set draw tags in azones, and future region tabs etc */
125 void ED_area_overdraw_flush(bContext *C)
126 {
127         ScrArea *sa;
128         
129         for(sa= CTX_wm_screen(C)->areabase.first; sa; sa= sa->next) {
130                 ARegion *ar;
131                 
132                 for(ar= sa->regionbase.first; ar; ar= ar->next) {
133                         if(ar->do_draw) {
134                                 AZone *az;
135                                 
136                                 for(az= sa->actionzones.first; az; az= az->next) {
137                                         int xs= (az->x1+az->x2)/2, ys= (az->y1+az->y2)/2;
138                 
139                                         /* test if inside */
140                                         if(BLI_in_rcti(&ar->winrct, xs, ys)) {
141                                                 az->do_draw= 1;
142                                         }
143                                 }
144                         }
145                 }
146         }       
147 }
148
149 void ED_area_overdraw(bContext *C)
150 {
151         wmWindow *win= CTX_wm_window(C);
152         bScreen *screen= CTX_wm_screen(C);
153         ScrArea *sa;
154         
155         /* Draw AZones, in screenspace */
156         wmSubWindowSet(win, screen->mainwin);
157
158         glEnable( GL_BLEND );
159         glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
160         
161         for(sa= screen->areabase.first; sa; sa= sa->next) {
162                 AZone *az;
163                 for(az= sa->actionzones.first; az; az= az->next) {
164                         if(az->do_draw) {
165                                 if(az->type==AZONE_TRI) {
166                                         glColor4ub(0, 0, 0, 70);
167                                         sdrawtrifill(az->x1, az->y1, az->x2, az->y2);
168                                 }
169                                 az->do_draw= 0;
170                         }
171                 }
172         }       
173         glDisable( GL_BLEND );
174         
175 }
176
177 void ED_region_do_draw(bContext *C, ARegion *ar)
178 {
179         wmWindow *win= CTX_wm_window(C);
180         ScrArea *sa= CTX_wm_area(C);
181         ARegionType *at= ar->type;
182         
183         /* note; this sets state, so we can use wmOrtho and friends */
184         wmSubWindowSet(win, ar->swinid);
185         
186         if(ar->swinid) {
187                 /* optional header info instead? */
188                 if(ar->headerstr) {
189                         float col[3];
190                         UI_SetTheme(sa);
191                         UI_GetThemeColor3fv(TH_HEADER, col);
192                         glClearColor(col[0], col[1], col[2], 0.0);
193                         glClear(GL_COLOR_BUFFER_BIT);
194                         
195                         UI_ThemeColor(TH_MENU_TEXT);
196                         glRasterPos2i(20, 6);
197                         BMF_DrawString(G.font, ar->headerstr);
198                 }
199                 else if(at->draw) {
200                         UI_SetTheme(sa);
201                         at->draw(C, ar);
202                         UI_SetTheme(NULL);
203                 }
204                 
205                 if(sa)
206                         region_draw_emboss(ar);
207
208                 uiFreeInactiveBlocks(C, &ar->uiblocks);
209                 
210                 /* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */
211                 ED_region_pixelspace(ar);
212         }
213         
214         ar->do_draw= 0;
215 }
216
217 /* **********************************
218    maybe silly, but let's try for now
219    to keep do_draw tags protected
220    ********************************** */
221
222 void ED_region_tag_redraw(ARegion *ar)
223 {
224         if(ar)
225                 ar->do_draw= 1;
226 }
227
228 void ED_area_tag_redraw(ScrArea *sa)
229 {
230         ARegion *ar;
231         
232         if(sa)
233                 for(ar= sa->regionbase.first; ar; ar= ar->next)
234                         ar->do_draw= 1;
235 }
236
237
238 /* *************************************************************** */
239
240 /* use NULL to disable it */
241 void ED_area_headerprint(ScrArea *sa, const char *str)
242 {
243         ARegion *ar;
244         
245         for(ar= sa->regionbase.first; ar; ar= ar->next) {
246                 if(ar->regiontype==RGN_TYPE_HEADER) {
247                         if(str) {
248                                 if(ar->headerstr==NULL)
249                                         ar->headerstr= MEM_mallocN(256, "headerprint");
250                                 BLI_strncpy(ar->headerstr, str, 256);
251                         }
252                         else if(ar->headerstr) {
253                                 MEM_freeN(ar->headerstr);
254                                 ar->headerstr= NULL;
255                         }
256                         ED_region_tag_redraw(ar);
257                 }
258         }
259 }
260
261 /* *************************************************************** */
262
263 /* dir is direction to check, not the splitting edge direction! */
264 static int rct_fits(rcti *rect, char dir, int size)
265 {
266         if(dir=='h') {
267                 return rect->xmax-rect->xmin - size;
268         }
269         else { // 'v'
270                 return rect->ymax-rect->ymin - size;
271         }
272 }
273
274 static void region_rect_recursive(ARegion *ar, rcti *remainder)
275 {
276         int prefsizex, prefsizey;
277         
278         if(ar==NULL)
279                 return;
280         
281         /* clear state flags first */
282         ar->flag &= ~RGN_FLAG_TOO_SMALL;
283         if(ar->next==NULL)
284                 ar->alignment= RGN_ALIGN_NONE;
285         
286         prefsizex= ar->type->minsizex;
287         prefsizey= ar->type->minsizey;
288         
289         /* hidden is user flag */
290         if(ar->flag & RGN_FLAG_HIDDEN);
291         /* XXX floating area region, not handled yet here */
292         else if(ar->alignment == RGN_ALIGN_FLOAT);
293         /* remainder is too small for any usage */
294         else if( rct_fits(remainder, 'v', 1)<0 || rct_fits(remainder, 'h', 1) < 0 ) {
295                 ar->flag |= RGN_FLAG_TOO_SMALL;
296         }
297         else if(ar->alignment==RGN_ALIGN_NONE) {
298                 /* typically last region */
299                 ar->winrct= *remainder;
300                 BLI_init_rcti(remainder, 0, 0, 0, 0);
301         }
302         else if(ar->alignment==RGN_ALIGN_TOP || ar->alignment==RGN_ALIGN_BOTTOM) {
303                 
304                 if( rct_fits(remainder, 'v', prefsizey) < 0 ) {
305                         ar->flag |= RGN_FLAG_TOO_SMALL;
306                 }
307                 else {
308                         int fac= rct_fits(remainder, 'v', prefsizey);
309
310                         if(fac < 0 )
311                                 prefsizey += fac;
312                         
313                         ar->winrct= *remainder;
314                         
315                         if(ar->alignment==RGN_ALIGN_TOP) {
316                                 ar->winrct.ymin= ar->winrct.ymax - prefsizey + 1;
317                                 remainder->ymax= ar->winrct.ymin - 1;
318                         }
319                         else {
320                                 ar->winrct.ymax= ar->winrct.ymin + prefsizey - 1;
321                                 remainder->ymin= ar->winrct.ymax + 1;
322                         }
323                 }
324         }
325         else if(ar->alignment==RGN_ALIGN_LEFT || ar->alignment==RGN_ALIGN_RIGHT) {
326                 
327                 if( rct_fits(remainder, 'h', prefsizex) < 0 ) {
328                         ar->flag |= RGN_FLAG_TOO_SMALL;
329                 }
330                 else {
331                         int fac= rct_fits(remainder, 'h', prefsizex);
332                         
333                         if(fac < 0 )
334                                 prefsizex += fac;
335                         
336                         ar->winrct= *remainder;
337                         
338                         if(ar->alignment==RGN_ALIGN_RIGHT) {
339                                 ar->winrct.xmin= ar->winrct.xmax - prefsizex + 1;
340                                 remainder->xmax= ar->winrct.xmin - 1;
341                         }
342                         else {
343                                 ar->winrct.xmax= ar->winrct.xmin + prefsizex - 1;
344                                 remainder->xmin= ar->winrct.xmax + 1;
345                         }
346                 }
347         }
348         else {
349                 /* percentage subdiv*/
350                 ar->winrct= *remainder;
351                 
352                 if(ar->alignment==RGN_ALIGN_HSPLIT) {
353                         if( rct_fits(remainder, 'h', prefsizex) > 4) {
354                                 ar->winrct.xmax= (remainder->xmin+remainder->xmax)/2;
355                                 remainder->xmin= ar->winrct.xmax+1;
356                         }
357                         else {
358                                 BLI_init_rcti(remainder, 0, 0, 0, 0);
359                         }
360                 }
361                 else {
362                         if( rct_fits(remainder, 'v', prefsizey) > 4) {
363                                 ar->winrct.ymax= (remainder->ymin+remainder->ymax)/2;
364                                 remainder->ymin= ar->winrct.ymax+1;
365                         }
366                         else {
367                                 BLI_init_rcti(remainder, 0, 0, 0, 0);
368                         }
369                 }
370         }
371         /* for speedup */
372         ar->winx= ar->winrct.xmax - ar->winrct.xmin + 1;
373         ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1;
374         
375         region_rect_recursive(ar->next, remainder);
376 }
377
378 static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
379 {
380         
381         if(sa->v1->vec.x>0) sa->totrct.xmin= sa->v1->vec.x+1;
382         else sa->totrct.xmin= sa->v1->vec.x;
383         if(sa->v4->vec.x<sizex-1) sa->totrct.xmax= sa->v4->vec.x-1;
384         else sa->totrct.xmax= sa->v4->vec.x;
385         
386         if(sa->v1->vec.y>0) sa->totrct.ymin= sa->v1->vec.y+1;
387         else sa->totrct.ymin= sa->v1->vec.y;
388         if(sa->v2->vec.y<sizey-1) sa->totrct.ymax= sa->v2->vec.y-1;
389         else sa->totrct.ymax= sa->v2->vec.y;
390         
391         /* for speedup */
392         sa->winx= sa->totrct.xmax-sa->totrct.xmin+1;
393         sa->winy= sa->totrct.ymax-sa->totrct.ymin+1;
394 }
395
396
397 #define AZONESPOT               12
398 void area_azone_initialize(ScrArea *sa) 
399 {
400         AZone *az;
401         if(sa->actionzones.first==NULL) {
402                 /* set action zones - should these actually be ARegions? With these we can easier check area hotzones */
403                 /* (ton) for time being just area, ARegion split is not foreseen on user level */
404                 az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
405                 BLI_addtail(&(sa->actionzones), az);
406                 az->type= AZONE_TRI;
407                 az->pos= AZONE_SW;
408                 
409                 az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
410                 BLI_addtail(&(sa->actionzones), az);
411                 az->type= AZONE_TRI;
412                 az->pos= AZONE_NE;
413         }
414         
415         for(az= sa->actionzones.first; az; az= az->next) {
416                 if(az->pos==AZONE_SW) {
417                         az->x1= sa->v1->vec.x+1;
418                         az->y1= sa->v1->vec.y+1;
419                         az->x2= sa->v1->vec.x+AZONESPOT;
420                         az->y2= sa->v1->vec.y+AZONESPOT;
421                 } 
422                 else if (az->pos==AZONE_NE) {
423                         az->x1= sa->v3->vec.x;
424                         az->y1= sa->v3->vec.y;
425                         az->x2= sa->v3->vec.x-AZONESPOT;
426                         az->y2= sa->v3->vec.y-AZONESPOT;
427                 }
428         }
429 }
430
431 /* used for area initialize below */
432 static void region_subwindow(wmWindowManager *wm, wmWindow *win, ARegion *ar)
433 {
434         if(ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) {
435                 if(ar->swinid)
436                         wm_subwindow_close(win, ar->swinid);
437                 ar->swinid= 0;
438         }
439         else if(ar->swinid==0)
440                 ar->swinid= wm_subwindow_open(win, &ar->winrct);
441         else 
442                 wm_subwindow_position(win, ar->swinid, &ar->winrct);
443 }
444
445 static void ed_default_handlers(wmWindowManager *wm, ListBase *handlers, int flag)
446 {
447         /* note, add-handler checks if it already exists */
448         
449         // XXX it would be good to have boundbox checks for some of these...
450         if(flag & ED_KEYMAP_UI) {
451                 UI_add_region_handlers(handlers);
452         }
453         if(flag & ED_KEYMAP_VIEW2D) {
454                 ListBase *keymap= WM_keymap_listbase(wm, "View2D", 0, 0);
455                 WM_event_add_keymap_handler(handlers, keymap);
456         }
457         if(flag & ED_KEYMAP_MARKERS) {
458                 ListBase *keymap= WM_keymap_listbase(wm, "Markers", 0, 0);
459                 WM_event_add_keymap_handler(handlers, keymap);
460                 // XXX need boundbox check urgently!!!
461         }
462         if(flag & ED_KEYMAP_ANIMATION) {
463                 ListBase *keymap= WM_keymap_listbase(wm, "Animation", 0, 0);
464                 WM_event_add_keymap_handler(handlers, keymap);
465         }
466 }
467
468
469 /* called in screen_refresh, or screens_init, also area size changes */
470 void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
471 {
472         ARegion *ar;
473         rcti rect;
474         
475         /* set typedefinitions */
476         sa->type= BKE_spacetype_from_id(sa->spacetype);
477         
478         if(sa->type==NULL) {
479                 sa->butspacetype= sa->spacetype= SPACE_VIEW3D;
480                 sa->type= BKE_spacetype_from_id(sa->spacetype);
481         }
482         
483         for(ar= sa->regionbase.first; ar; ar= ar->next)
484                 ar->type= ED_regiontype_from_id(sa->type, ar->regiontype);
485         
486         /* area sizes */
487         area_calc_totrct(sa, win->sizex, win->sizey);
488         
489         /* region rect sizes */
490         rect= sa->totrct;
491         region_rect_recursive(sa->regionbase.first, &rect);
492         
493         /* default area handlers */
494         ed_default_handlers(wm, &sa->handlers, sa->type->keymapflag);
495         /* checks spacedata, adds own handlers */
496         if(sa->type->init)
497                 sa->type->init(wm, sa);
498         
499         /* region windows, default and own handlers */
500         for(ar= sa->regionbase.first; ar; ar= ar->next) {
501                 region_subwindow(wm, win, ar);
502                 
503                 /* default region handlers */
504                 ed_default_handlers(wm, &ar->handlers, ar->type->keymapflag);
505
506                 if(ar->type->init)
507                         ar->type->init(wm, ar);
508                 
509         }
510         area_azone_initialize(sa);
511 }
512
513 /* externally called for floating regions like menus */
514 void ED_region_init(bContext *C, ARegion *ar)
515 {
516 //      ARegionType *at= ar->type;
517         
518         /* refresh can be called before window opened */
519         region_subwindow(CTX_wm_manager(C), CTX_wm_window(C), ar);
520         
521 }
522
523
524 /* sa2 to sa1, we swap spaces for fullscreen to keep all allocated data */
525 /* area vertices were set */
526 void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space)
527 {
528         ARegion *ar;
529         
530         sa1->headertype= sa2->headertype;
531         sa1->spacetype= sa2->spacetype;
532         sa1->butspacetype= sa2->butspacetype;
533         
534         if(swap_space) {
535                 SWAP(ListBase, sa1->spacedata, sa2->spacedata);
536                 /* exception: ensure preview is reset */
537 //              if(sa1->spacetype==SPACE_VIEW3D)
538 // XXX                  BIF_view3d_previewrender_free(sa1->spacedata.first);
539         }
540         else {
541                 BKE_spacedata_freelist(&sa1->spacedata);
542                 BKE_spacedata_copylist(&sa1->spacedata, &sa2->spacedata);
543         }
544         
545         /* regions... XXX */
546         BLI_freelistN(&sa1->regionbase);
547         
548         for(ar= sa2->regionbase.first; ar; ar= ar->next) {
549                 ARegion *newar= BKE_area_region_copy(ar);
550                 BLI_addtail(&sa1->regionbase, newar);
551         }
552                 
553 #ifndef DISABLE_PYTHON
554         /* scripts */
555         BPY_free_scriptlink(&sa1->scriptlink);
556         sa1->scriptlink= sa2->scriptlink;
557         BPY_copy_scriptlink(&sa1->scriptlink);  /* copies internal pointers */
558 #endif
559 }
560
561 /* *********** Space switching code, local now *********** */
562 /* XXX make operator for this */
563
564 void area_newspace(bContext *C, ScrArea *sa, int type)
565 {
566         if(sa->spacetype != type) {
567                 SpaceType *st;
568                 SpaceLink *slold;
569                 SpaceLink *sl;
570
571                 ED_area_exit(C, sa);
572
573                 st= BKE_spacetype_from_id(type);
574                 slold= sa->spacedata.first;
575
576                 sa->spacetype= type;
577                 sa->butspacetype= type;
578                 sa->type= st;
579                 
580                 /* check previously stored space */
581                 for (sl= sa->spacedata.first; sl; sl= sl->next)
582                         if(sl->spacetype==type)
583                                 break;
584                 
585                 /* old spacedata... happened during work on 2.50, remove */
586                 if(sl && sl->regionbase.first==NULL) {
587                         st->free(sl);
588                         BLI_freelinkN(&sa->spacedata, sl);
589                         sl= NULL;
590                 }
591                 
592                 if (sl) {
593                         
594                         /* swap regions */
595                         slold->regionbase= sa->regionbase;
596                         sa->regionbase= sl->regionbase;
597                         sl->regionbase.first= sl->regionbase.last= NULL;
598                         
599                         /* put in front of list */
600                         BLI_remlink(&sa->spacedata, sl);
601                         BLI_addhead(&sa->spacedata, sl);
602                 } 
603                 else {
604                         /* new space */
605                         if(st) {
606                                 sl= st->new(C);
607                                 BLI_addhead(&sa->spacedata, sl);
608                                 
609                                 /* swap regions */
610                                 if(slold)
611                                         slold->regionbase= sa->regionbase;
612                                 sa->regionbase= sl->regionbase;
613                                 sl->regionbase.first= sl->regionbase.last= NULL;
614                         }
615                 }
616                 
617                 ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
618                 
619                 /* tell WM to refresh, cursor types etc */
620                 WM_event_add_mousemove(C);
621         }
622 }
623
624 static char *windowtype_pup(void)
625 {
626         return(
627                    "Window type:%t" //14
628                    "|3D View %x1" //30
629                    
630                    "|%l" // 33
631                    
632                    "|Ipo Curve Editor %x2" //54
633                    "|Action Editor %x12" //73
634                    "|NLA Editor %x13" //94
635                    
636                    "|%l" //97
637                    
638                    "|UV/Image Editor %x6" //117
639                    
640                    "|Video Sequence Editor %x8" //143
641                    "|Timeline %x15" //163
642                    "|Audio Window %x11" //163
643                    "|Text Editor %x9" //179
644                    
645                    "|%l" //192
646                    
647                    
648                    "|User Preferences %x7" //213
649                    "|Outliner %x3" //232
650                    "|Buttons Window %x4" //251
651                    "|Node Editor %x16"
652                    "|%l" //254
653                    
654                    "|File Browser %x5" //290
655                    
656                    "|%l" //293
657                    
658                    "|Scripts Window %x14"//313
659                    );
660 }
661
662 static void spacefunc(struct bContext *C, void *arg1, void *arg2)
663 {
664         area_newspace(C, CTX_wm_area(C), CTX_wm_area(C)->butspacetype);
665         ED_area_tag_redraw(CTX_wm_area(C));
666 }
667
668 /* returns offset for next button in header */
669 int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
670 {
671         ScrArea *sa= CTX_wm_area(C);
672         uiBut *but;
673         int xco= 8;
674         
675         if(ED_screen_area_active(C)) uiBlockSetCol(block, TH_HEADER);
676         else uiBlockSetCol(block, TH_HEADERDESEL);
677         
678         but= uiDefIconTextButC(block, ICONTEXTROW, 0, ICON_VIEW3D, 
679                                                    windowtype_pup(), xco, yco, XIC+10, YIC, 
680                                                    &(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0, 
681                                                    "Displays Current Window Type. "
682                                                    "Click for menu of available types.");
683         uiButSetFunc(but, spacefunc, NULL, NULL);
684         
685         xco += XIC + 14;
686         
687         uiBlockSetEmboss(block, UI_EMBOSSN);
688         if (sa->flag & HEADER_NO_PULLDOWN) {
689                 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, 
690                                                  ICON_DISCLOSURE_TRI_RIGHT,
691                                                  xco,yco,XIC,YIC-2,
692                                                  &(sa->flag), 0, 0, 0, 0, 
693                                                  "Show pulldown menus");
694         }
695         else {
696                 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, 
697                                                  ICON_DISCLOSURE_TRI_DOWN,
698                                                  xco,yco,XIC,YIC-2,
699                                                  &(sa->flag), 0, 0, 0, 0, 
700                                                  "Hide pulldown menus");
701         }
702         xco+=XIC;
703         
704         return xco;
705 }
706