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;
46 #define UI_EMBOSS 0 /* use one of the themes for drawing */
47 #define UI_EMBOSSN 1 /* Nothing */
48 #define UI_EMBOSSM 2 /* Minimal builtin emboss, also for logic buttons */
49 #define UI_EMBOSSP 3 /* Pulldown */
50 #define UI_EMBOSSR 4 /* Rounded */
51 #define UI_EMBOSST 5 /* Table */
53 #define UI_EMBOSSX 0 /* for a python file, which i can't change.... duh! */
55 /* uiBlock->direction */
60 #define UI_DIRECTION 15
62 #define UI_SHIFT_FLIPPED 32
64 /* uiBlock->autofill */
65 #define UI_BLOCK_COLLUMNS 1
66 #define UI_BLOCK_ROWS 2
68 /* uiBlock->flag (controls) */
69 #define UI_BLOCK_LOOP 1
70 #define UI_BLOCK_REDRAW 2
71 #define UI_BLOCK_RET_1 4 /* XXX 2.5 not implemented */
72 #define UI_BLOCK_NUMSELECT 8
73 #define UI_BLOCK_ENTER_OK 16
74 #define UI_BLOCK_NOSHADOW 32
75 #define UI_BLOCK_NO_HILITE 64 /* XXX 2.5 not implemented */
76 #define UI_BLOCK_MOVEMOUSE_QUIT 128
77 #define UI_BLOCK_KEEP_OPEN 256
79 /* uiMenuBlockHandle->menuretval */
80 #define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
81 #define UI_RETURN_OK 2 /* choice made */
82 #define UI_RETURN_OUT 4 /* left the menu */
84 /* block->flag bits 12-15 are identical to but->flag bits */
86 /* block->font, for now: bold = medium+1 */
91 #define UI_PNL_TRANSP 1
92 #define UI_PNL_SOLID 2
94 #define UI_PNL_CLOSE 32
95 #define UI_PNL_STOW 64
96 #define UI_PNL_TO_MOUSE 128
97 #define UI_PNL_UNSTOW 256
98 #define UI_PNL_SCALE 512
100 /* warning the first 4 flags are internal */
102 #define UI_TEXT_LEFT 16
103 #define UI_ICON_LEFT 32
104 #define UI_ICON_RIGHT 64
105 /* control for button type block */
106 #define UI_MAKE_TOP 128
107 #define UI_MAKE_DOWN 256
108 #define UI_MAKE_LEFT 512
109 #define UI_MAKE_RIGHT 1024
110 /* dont draw hilite on mouse over */
111 #define UI_NO_HILITE 2048
112 /* button align flag, for drawing groups together */
113 #define UI_BUT_ALIGN (15<<12)
114 #define UI_BUT_ALIGN_TOP (1<<12)
115 #define UI_BUT_ALIGN_LEFT (1<<13)
116 #define UI_BUT_ALIGN_RIGHT (1<<14)
117 #define UI_BUT_ALIGN_DOWN (1<<15)
120 /* Button types, bits stored in 1 value... and a short even!
121 - bits 0-4: bitnr (0-31)
122 - bits 5-7: pointer type
124 - bit 9-15: button type (now 6 bits, 64 types)
134 #define BUTPOIN (128+64+32)
145 #define LABEL (10<<9)
147 #define ICONROW (12<<9)
148 #define ICONTOG (13<<9)
149 #define NUMSLI (14<<9)
151 #define IDPOIN (16<<9)
152 #define HSVSLI (17<<9)
153 #define SCROLL (18<<9)
154 #define BLOCK (19<<9)
158 #define INLINK (23<<9)
159 #define KEYEVT (24<<9)
160 #define ICONTEXTROW (25<<9)
161 #define HSVCUBE (26<<9)
162 #define PULLDOWN (27<<9)
163 #define ROUNDBOX (28<<9)
164 #define CHARTAB (29<<9)
165 #define BUT_COLORBAND (30<<9)
166 #define BUT_NORMAL (31<<9)
167 #define BUT_CURVE (32<<9)
168 #define BUT_TOGDUAL (33<<9)
169 #define ICONTOGN (34<<9)
170 #define FTPREVIEW (35<<9)
171 #define NUMABS (36<<9)
172 #define BUTTYPE (63<<9)
174 typedef struct uiBut uiBut;
175 typedef struct uiBlock uiBlock;
177 /* Common Drawing Functions */
179 void uiEmboss(float x1, float y1, float x2, float y2, int sel);
180 void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad);
181 void uiSetRoundBox(int type);
182 void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad);
183 void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, short direction);
184 void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
188 typedef struct uiMenuBlockHandle {
190 struct ARegion *region;
191 int towardsx, towardsy;
196 void (*popup_func)(struct bContext *C, void *arg, int event);
198 /* for operator menus */
199 struct wmOperator *op_arg;
200 const char *propname;
209 typedef uiBlock* (*uiBlockFuncFP)(struct bContext *C, struct uiMenuBlockHandle *handle, void *arg1);
210 typedef void (*uiPupmenuFunc)(struct bContext *C, void *arg, int event);
212 void uiPupmenuSetActive(int val);
214 void uiPupmenuOperator(struct bContext *C, int maxrow, struct wmOperator *op, const char *propname, char *str);
215 void uiPupmenu(struct bContext *C, int maxrow, uiPupmenuFunc func, void *arg, char *str, ...);
216 void uiPupmenuOkee(struct bContext *C, char *opname, char *str, ...);
217 void uiPupmenuSaveOver(struct bContext *C, char *opname, char *filename, ...);
218 void uiPupmenuNotice(struct bContext *C, char *str, ...);
219 void uiPupmenuError(struct bContext *C, char *str, ...);
220 void uiPupmenuReports(struct bContext *C, struct ReportList *reports);
224 uiBlock *uiBeginBlock(const struct bContext *C, struct ARegion *region, char *name, short dt, short font);
225 void uiEndBlock(const struct bContext *C, uiBlock *block);
226 void uiDrawBlock(const struct bContext *C, struct uiBlock *block);
227 uiBlock *uiGetBlock(char *name, struct ARegion *ar);
228 void uiFreeBlock(const struct bContext *C, uiBlock *block);
229 void uiFreeBlocks(const struct bContext *C, struct ListBase *lb);
230 void uiFreeInactiveBlocks(const struct bContext *C, struct ListBase *lb);
232 void uiBoundsBlock(struct uiBlock *block, int addval);
233 void uiTextBoundsBlock(uiBlock *block, int addval);
235 void uiBlockSetButLock(uiBlock *block, int val, char *lockstr);
236 void uiBlockClearButLock(uiBlock *block);
238 /* automatic aligning, horiz or verical */
239 void uiBlockBeginAlign(uiBlock *block);
240 void uiBlockEndAlign(uiBlock *block);
244 void uiSetCurFont(uiBlock *block, int index);
245 void *uiSetCurFont_ext(float aspect);
246 void uiDefFont(unsigned int index, void *xl, void *large, void *medium, void *small);
248 void uiComposeLinks(uiBlock *block);
249 uiBut *uiFindInlink(uiBlock *block, void *poin);
251 void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
253 /* Defining Buttons */
255 uiBut *uiDefBut(uiBlock *block,
256 int type, int retval, char *str,
260 float min, float max,
261 float a1, float a2, char *tip);
262 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);
263 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);
264 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);
265 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);
266 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);
267 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);
268 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);
269 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);
270 uiBut *uiDefButR(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip);
271 uiBut *uiDefButO(struct bContext *C, uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip);
273 uiBut *uiDefIconBut(uiBlock *block,
274 int type, int retval, int icon,
278 float min, float max,
279 float a1, float a2, char *tip);
280 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);
281 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);
282 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);
283 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);
284 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);
285 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);
286 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);
287 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);
288 uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip);
289 uiBut *uiDefIconButO(struct bContext *C, uiBlock *block, int type, char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip);
291 uiBut *uiDefIconTextBut(uiBlock *block,
292 int type, int retval, int icon, char *str,
296 float min, float max,
297 float a1, float a2, char *tip);
298 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);
299 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);
300 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);
301 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);
302 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);
303 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);
304 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);
305 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);
306 uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip);
307 uiBut *uiDefIconTextButO(struct bContext *C, uiBlock *block, int type, char *opname, int opcontext, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
309 typedef void (*uiIDPoinFuncFP) (struct bContext *C, char *str, struct ID **idpp);
310 uiBut *uiDefIDPoinBut(struct uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
311 short x1, short y1, short x2, short y2, void *idpp, char *tip);
313 uiBut *uiDefBlockBut(uiBlock *block, uiBlockFuncFP func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
314 uiBut *uiDefPulldownBut(uiBlock *block, uiBlockFuncFP func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
316 uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
317 uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int retval, int icon, short x1, short y1, short x2, short y2, char *tip);
319 void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
321 void uiAutoBlock(struct uiBlock *block,
322 float minx, float miny,
323 float sizex, float sizey, int flag);
324 void uiSetButLink(struct uiBut *but,
330 int uiBlocksGetYMin (ListBase *lb);
331 int uiBlockGetCol (uiBlock *block);
332 void* uiBlockGetCurFont (uiBlock *block);
334 void uiBlockSetCol (uiBlock *block, int col);
335 void uiBlockSetEmboss (uiBlock *block, int emboss);
336 void uiBlockSetDirection (uiBlock *block, int direction);
337 void uiBlockFlipOrder (uiBlock *block);
338 void uiBlockSetFlag (uiBlock *block, int flag);
339 void uiBlockSetXOfs (uiBlock *block, int xofs);
341 int uiButGetRetVal (uiBut *but);
343 void uiButSetFlag (uiBut *but, int flag);
344 void uiButClearFlag (uiBut *but, int flag);
346 struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but);
348 void uiBlockSetHandleFunc(uiBlock *block, void (*func)(struct bContext *C, void *arg, int event), void *arg);
349 void uiBlockSetButmFunc (uiBlock *block, void (*func)(struct bContext *C, void *arg, int but_a2), void *arg);
351 void uiBlockSetFunc (uiBlock *block, void (*func)(struct bContext *C, void *arg1, void *arg2), void *arg1, void *arg2);
352 void uiButSetFunc (uiBut *but, void (*func)(struct bContext *C, void *arg1, void *arg2), void *arg1, void *arg2);
354 void uiButSetCompleteFunc(uiBut *but, void (*func)(struct bContext *C, char *str, void *arg), void *arg);
356 void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(struct bContext *C, uiBlock *block));
360 extern void uiFreePanels(struct ListBase *lb);
361 extern void uiNewPanelTabbed(char *, char *);
362 extern int uiNewPanel(const struct bContext *C, struct ARegion *ar, uiBlock *block, char *panelname, char *tabname, int ofsx, int ofsy, int sizex, int sizey);
363 extern void uiDrawPanels(const struct bContext *C, int re_align);
365 extern void uiSetPanelsView2d(struct ARegion *ar);
366 extern void uiMatchPanelsView2d(struct ARegion *ar);
368 extern void uiNewPanelHeight(struct uiBlock *block, int sizey);
369 extern void uiNewPanelTitle(struct uiBlock *block, char *str);
370 extern uiBlock *uiFindOpenPanelBlockName(ListBase *lb, char *name);
371 extern int uiAlignPanelStep(struct ScrArea *sa, struct ARegion *ar, float fac);
372 extern void uiPanelControl(int);
373 extern void uiSetPanelHandler(int);
377 typedef struct AutoComplete AutoComplete;
379 AutoComplete *autocomplete_begin(char *startname, int maxlen);
380 void autocomplete_do_name(AutoComplete *autocpl, const char *name);
381 void autocomplete_end(AutoComplete *autocpl, char *autoname);
383 /* Handlers for regions with UI blocks */
385 void UI_add_region_handlers(struct ListBase *handlers);
386 void UI_add_area_handlers(struct ListBase *handlers);
387 void UI_add_popup_handlers(struct ListBase *handlers, uiMenuBlockHandle *menu);
389 /* Module initialization and exit */
392 void UI_init_userdef(void);
395 #endif /* UI_INTERFACE_H */