Blender  V2.59
script_header.c
Go to the documentation of this file.
00001 /*
00002  * $Id: script_header.c 37185 2011-06-04 17:03:46Z ton $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version. 
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2008 Blender Foundation.
00021  * All rights reserved.
00022  *
00023  * 
00024  * Contributor(s): Blender Foundation
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00034 #include <string.h>
00035 #include <stdio.h>
00036 
00037 #include "BLI_blenlib.h"
00038 #include "BLI_utildefines.h"
00039 
00040 
00041 #include "BKE_context.h"
00042 
00043 #include "ED_screen.h"
00044 #include "ED_types.h"
00045 #include "ED_util.h"
00046 
00047 #include "UI_interface.h"
00048 #include "UI_resources.h"
00049 #include "UI_view2d.h"
00050 
00051 #include "script_intern.h"
00052 
00053 /* ************************ header area region *********************** */
00054 
00055 static void do_viewmenu(bContext *UNUSED(C), void *UNUSED(arg), int UNUSED(event))
00056 {
00057         
00058 }
00059 
00060 static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *UNUSED(arg))
00061 {
00062         ScrArea *curarea= CTX_wm_area(C);
00063         uiBlock *block;
00064         short yco= 0, menuwidth=120;
00065         
00066         block= uiBeginBlock(C, ar, "dummy_viewmenu", UI_EMBOSSP);
00067         uiBlockSetButmFunc(block, do_viewmenu, NULL);
00068         
00069         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20, 
00070                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
00071         
00072         if(curarea->headertype==HEADERTOP) {
00073                 uiBlockSetDirection(block, UI_DOWN);
00074         }
00075         else {
00076                 uiBlockSetDirection(block, UI_TOP);
00077                 uiBlockFlipOrder(block);
00078         }
00079         
00080         uiTextBoundsBlock(block, 50);
00081         uiEndBlock(C, block);
00082         
00083         return block;
00084 }
00085 
00086 static void do_script_buttons(bContext *UNUSED(C), void *UNUSED(arg), int UNUSED(event))
00087 {
00088         //switch(event) {
00089         //}
00090 }
00091 
00092 
00093 void script_header_buttons(const bContext *C, ARegion *ar)
00094 {
00095         ScrArea *sa= CTX_wm_area(C);
00096         uiBlock *block;
00097         int xco, yco= 3;
00098         
00099         block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
00100         uiBlockSetHandleFunc(block, do_script_buttons, NULL);
00101         
00102         xco= ED_area_header_standardbuttons(C, block, yco);
00103         
00104         if((sa->flag & HEADER_NO_PULLDOWN)==0) {
00105                 int xmax;
00106                 
00107                 xmax= GetButStringLength("View");
00108                 uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), 
00109                                                  "View", xco, yco-2, xmax-3, UI_UNIT_Y, "");
00110                 xco+=UI_UNIT_X+xmax;
00111         }
00112         
00113         uiBlockSetEmboss(block, UI_EMBOSS);
00114 
00115         /* always as last  */
00116         UI_view2d_totRect_set(&ar->v2d, xco+UI_UNIT_X+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
00117         
00118         uiEndBlock(C, block);
00119         uiDrawBlock(C, block);
00120 }
00121 
00122