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 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
30 #ifndef UI_INTERFACE_H
31 #define UI_INTERFACE_H
37 struct wmWindowManager;
44 #define UI_EMBOSS 0 /* use one of the themes for drawing */
45 #define UI_EMBOSSN 1 /* Nothing */
46 #define UI_EMBOSSM 2 /* Minimal builtin emboss, also for logic buttons */
47 #define UI_EMBOSSP 3 /* Pulldown */
48 #define UI_EMBOSSR 4 /* Rounded */
49 #define UI_EMBOSST 5 /* Table */
51 #define UI_EMBOSSX 0 /* for a python file, which i can't change.... duh! */
53 /* uiBlock->direction */
58 #define UI_DIRECTION 15
60 #define UI_SHIFT_FLIPPED 32
62 /* uiBlock->autofill */
63 #define UI_BLOCK_COLLUMNS 1
64 #define UI_BLOCK_ROWS 2
66 /* uiBlock->flag (controls) */
67 #define UI_BLOCK_LOOP 1
68 #define UI_BLOCK_REDRAW 2
69 #define UI_BLOCK_RET_1 4 /* XXX 2.5 not implemented */
70 #define UI_BLOCK_NUMSELECT 8
71 #define UI_BLOCK_ENTER_OK 16
72 #define UI_BLOCK_NOSHADOW 32
73 #define UI_BLOCK_NO_HILITE 64 /* XXX 2.5 not implemented */
74 #define UI_BLOCK_MOVEMOUSE_QUIT 128
75 #define UI_BLOCK_KEEP_OPEN 256
77 /* uiMenuBlockHandle->menuretval */
78 #define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
79 #define UI_RETURN_OK 2 /* choice made */
80 #define UI_RETURN_OUT 4 /* left the menu */
82 /* block->flag bits 12-15 are identical to but->flag bits */
84 /* block->font, for now: bold = medium+1 */
89 #define UI_PNL_TRANSP 1
90 #define UI_PNL_SOLID 2
92 #define UI_PNL_CLOSE 32
93 #define UI_PNL_STOW 64
94 #define UI_PNL_TO_MOUSE 128
95 #define UI_PNL_UNSTOW 256
96 #define UI_PNL_SCALE 512
98 /* warning the first 4 flags are internal */
100 #define UI_TEXT_LEFT 16
101 #define UI_ICON_LEFT 32
102 #define UI_ICON_RIGHT 64
103 /* control for button type block */
104 #define UI_MAKE_TOP 128
105 #define UI_MAKE_DOWN 256
106 #define UI_MAKE_LEFT 512
107 #define UI_MAKE_RIGHT 1024
108 /* dont draw hilite on mouse over */
109 #define UI_NO_HILITE 2048
110 /* button align flag, for drawing groups together */
111 #define UI_BUT_ALIGN (15<<12)
112 #define UI_BUT_ALIGN_TOP (1<<12)
113 #define UI_BUT_ALIGN_LEFT (1<<13)
114 #define UI_BUT_ALIGN_RIGHT (1<<14)
115 #define UI_BUT_ALIGN_DOWN (1<<15)
118 /* Button types, bits stored in 1 value... and a short even!
119 - bits 0-4: bitnr (0-31)
120 - bits 5-7: pointer type
122 - bit 9-15: button type (now 6 bits, 64 types)
132 #define BUTPOIN (128+64+32)
143 #define LABEL (10<<9)
145 #define ICONROW (12<<9)
146 #define ICONTOG (13<<9)
147 #define NUMSLI (14<<9)
149 #define IDPOIN (16<<9)
150 #define HSVSLI (17<<9)
151 #define SCROLL (18<<9)
152 #define BLOCK (19<<9)
156 #define INLINK (23<<9)
157 #define KEYEVT (24<<9)
158 #define ICONTEXTROW (25<<9)
159 #define HSVCUBE (26<<9)
160 #define PULLDOWN (27<<9)
161 #define ROUNDBOX (28<<9)
162 #define CHARTAB (29<<9)
163 #define BUT_COLORBAND (30<<9)
164 #define BUT_NORMAL (31<<9)
165 #define BUT_CURVE (32<<9)
166 #define BUT_TOGDUAL (33<<9)
167 #define ICONTOGN (34<<9)
168 #define FTPREVIEW (35<<9)
169 #define NUMABS (36<<9)
170 #define BUTTYPE (63<<9)
172 typedef struct uiBut uiBut;
173 typedef struct uiBlock uiBlock;
175 /* Common Drawing Functions */
177 void uiEmboss(float x1, float y1, float x2, float y2, int sel);
178 void uiRoundBoxEmboss(float minx, float miny, float maxx, float maxy, float rad, int active);
179 void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad);
180 void uiSetRoundBox(int type);
181 void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad);
182 void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag);
183 void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
187 typedef struct uiMenuBlockHandle {
188 struct ARegion *region;
196 typedef uiBlock* (*uiBlockFuncFP)(struct bContext *C, struct uiMenuBlockHandle *handle, void *arg1);
198 extern void pupmenu_set_active(int val);
199 extern uiMenuBlockHandle *pupmenu_col(struct bContext *C, char *instr, int mx, int my, int maxrow);
200 extern uiMenuBlockHandle *pupmenu(struct bContext *C, char *instr, int mx, int my);
201 extern void pupmenu_free(struct bContext *C, uiMenuBlockHandle *handle);
205 uiBlock *uiBeginBlock(const struct bContext *C, struct ARegion *region, char *name, short dt, short font);
206 void uiEndBlock(const struct bContext *C, uiBlock *block);
207 uiBlock *uiGetBlock(char *name, struct ARegion *ar);
208 void uiFreeBlock(const struct bContext *C, uiBlock *block);
209 void uiFreeBlocks(const struct bContext *C, struct ListBase *lb);
211 void uiBoundsBlock(struct uiBlock *block, int addval);
212 void uiDrawBlock(struct uiBlock *block);
213 void uiTextBoundsBlock(uiBlock *block, int addval);
215 void uiBlockSetButLock(uiBlock *block, int val, char *lockstr);
216 void uiBlockClearButLock(uiBlock *block);
218 /* automatic aligning, horiz or verical */
219 void uiBlockBeginAlign(uiBlock *block);
220 void uiBlockEndAlign(uiBlock *block);
224 void uiSetCurFont(uiBlock *block, int index);
225 void *uiSetCurFont_ext(float aspect);
226 void uiDefFont(unsigned int index, void *xl, void *large, void *medium, void *small);
228 void uiComposeLinks(uiBlock *block);
229 uiBut *uiFindInlink(uiBlock *block, void *poin);
231 void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
233 /* Defining Buttons */
235 uiBut *uiDefBut(uiBlock *block,
236 int type, int retval, char *str,
240 float min, float max,
241 float a1, float a2, char *tip);
242 uiBut *uiDefButF(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip);
243 uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip);
244 uiBut *uiDefButI(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip);
245 uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip);
246 uiBut *uiDefButS(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip);
247 uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip);
248 uiBut *uiDefButC(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
249 uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
251 uiBut *uiDefIconBut(uiBlock *block,
252 int type, int retval, int icon,
256 float min, float max,
257 float a1, float a2, char *tip);
258 uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip);
259 uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip);
260 uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip);
261 uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip);
262 uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip);
263 uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip);
264 uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
265 uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
267 uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip);
269 uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip);
270 uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip);
271 uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip);
272 uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip);
273 uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip);
274 uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip);
275 uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
276 uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
278 typedef void (*uiIDPoinFuncFP) (struct bContext *C, char *str, struct ID **idpp);
279 uiBut *uiDefIDPoinBut(struct uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
280 short x1, short y1, short x2, short y2, void *idpp, char *tip);
282 uiBut *uiDefBlockBut(uiBlock *block, uiBlockFuncFP func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
283 uiBut *uiDefPulldownBut(uiBlock *block, uiBlockFuncFP func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
285 uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
286 uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int retval, int icon, short x1, short y1, short x2, short y2, char *tip);
288 void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
290 uiBut *uiDefRNABut(uiBlock *block, int retval, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, short x1, short y1, short x2, short y2);
292 void uiAutoBlock(struct uiBlock *block,
293 float minx, float miny,
294 float sizex, float sizey, int flag);
295 void uiSetButLink(struct uiBut *but,
301 int uiBlocksGetYMin (ListBase *lb);
302 int uiBlockGetCol (uiBlock *block);
303 void* uiBlockGetCurFont (uiBlock *block);
305 void uiBlockSetCol (uiBlock *block, int col);
306 void uiBlockSetEmboss (uiBlock *block, int emboss);
307 void uiBlockSetDirection (uiBlock *block, int direction);
308 void uiBlockFlipOrder (uiBlock *block);
309 void uiBlockSetFlag (uiBlock *block, int flag);
310 void uiBlockSetXOfs (uiBlock *block, int xofs);
312 int uiButGetRetVal (uiBut *but);
314 void uiButSetFlag (uiBut *but, int flag);
315 void uiButClearFlag (uiBut *but, int flag);
317 void uiBlockSetHandleFunc(uiBlock *block, void (*func)(struct bContext *C, void *arg, int event), void *arg);
318 void uiBlockSetButmFunc (uiBlock *block, void (*func)(struct bContext *C, void *arg, int but_a2), void *arg);
320 void uiBlockSetFunc (uiBlock *block, void (*func)(struct bContext *C, void *arg1, void *arg2), void *arg1, void *arg2);
321 void uiButSetFunc (uiBut *but, void (*func)(struct bContext *C, void *arg1, void *arg2), void *arg1, void *arg2);
323 void uiButSetCompleteFunc(uiBut *but, void (*func)(struct bContext *C, char *str, void *arg), void *arg);
325 void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(struct bContext *C, uiBlock *block));
329 extern void uiFreePanels(struct ListBase *lb);
330 extern void uiNewPanelTabbed(char *, char *);
331 extern int uiNewPanel(struct ScrArea *sa, struct uiBlock *block, char *panelname, char *tabname, int ofsx, int ofsy, int sizex, int sizey);
333 extern void uiSetPanel_view2d(struct ScrArea *sa);
334 extern void uiMatchPanel_view2d(struct ScrArea *sa);
336 extern void uiDrawBlocksPanels(struct ScrArea *sa, int re_align);
337 extern void uiNewPanelHeight(struct uiBlock *block, int sizey);
338 extern void uiNewPanelTitle(struct uiBlock *block, char *str);
339 extern void uiPanelPush(struct uiBlock *block);
340 extern void uiPanelPop(struct uiBlock *block);
341 extern uiBlock *uiFindOpenPanelBlockName(ListBase *lb, char *name);
342 extern int uiAlignPanelStep(struct ScrArea *sa, float fac);
343 extern void uiPanelControl(int);
344 extern void uiSetPanelHandler(int);
348 typedef struct AutoComplete AutoComplete;
350 AutoComplete *autocomplete_begin(char *startname, int maxlen);
351 void autocomplete_do_name(AutoComplete *autocpl, const char *name);
352 void autocomplete_end(AutoComplete *autocpl, char *autoname);
354 /* Handlers for regions with UI blocks */
356 void UI_add_region_handlers(struct ListBase *handlers);
358 /* Module initialization and exit */
361 void UI_init_userdef(void);
364 void uiTestRegion(const struct bContext *C); /* XXX 2.50 temporary test */
366 #endif /* UI_INTERFACE_H */