1 /***************************************************************************
2                           item.h  -  description
3                              -------------------
4     begin                : Thu Sep 20 2001
5     copyright            : (C) 2001 by Michael Speck
6     email                : kulkanie@gmx.net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #ifndef __ITEM_H
19 #define __ITEM_H
20 
21 #include "hint.h"
22 
23 /*
24 ====================================================================
25 Item of menu
26 ====================================================================
27 */
28 enum {
29     ITEM_SEPARATOR = 0,
30     ITEM_SWITCH,
31     ITEM_SWITCH_X,
32     ITEM_RANGE,
33     ITEM_KEY,
34     ITEM_EDIT,
35     ITEM_LINK,
36     ITEM_ACTION
37 };
38 typedef struct {
39     Value   *value;         /* value of item */
40     int     type;           /* type as listed above */
41     char    *name;          /* name of item -- duplicated */
42     int     item_id;        /* id of item (returned as action if ITEM_ACTION) */
43     int     x, y, w, h;     /* position and size in screen */
44     int     nx, ny;         /* position where name is drawn */
45     int     nalign;         /* align of name: either left-aligned
46                                or centered (only if link to another menu) */
47     int     vx, vy;         /* position where value string is drawn right-aligned */
48     int     valign;         /* alignment of value string */
49     float   alpha;          /* alpha of normal font (which vanishes when selected) */
50     float   halpha;         /* alpha of highlight font */
51     int     highlighted;    /* keep alpha at 0 (will raise to 255 if not set) */
52     void    (*callback)();  /* if value of item has been modified this functions is called */
53     void    *link;          /* menu link */
54     Font    *font;          /* if set use this font instead of standard font */
55     Hint    *hint;          /* if not NULL this hint is displayed when quick-help's enabled:
56                                created by item itself */
57 } Item;
58 
59 /*
60 ====================================================================
61 Create item.
62 Return Value: item
63 ====================================================================
64 */
65 Item *item_create_separator( char *name );
66 Item *item_create_range(     char *name, char *hint, int  *val_int, int min, int max, int step );
67 Item *item_create_switch(    char *name, char *hint, int  *val_int, char *str_off, char *str_on );
68 Item *item_create_switch_x(  char *name, char *hint, int  *val_int, char **strings, int count );
69 Item *item_create_key(       char *name, char *hint, int  *val_int, int *filter );
70 Item *item_create_edit(      char *name, char *hint, char *val_str, int limit );
71 Item *item_create_link(      char *name, char *hint, void *menu );
72 Item *item_create_action(    char *name, char *hint, int item_id );
73 /*
74 ====================================================================
75 Delete item (void pointer for compatiblity when using with list)
76 ====================================================================
77 */
78 void item_delete( void *item );
79 /*
80 ====================================================================
81 Adjust alignment of name and value strings
82 ====================================================================
83 */
84 void item_adjust( Item *item );
85 /*
86 ====================================================================
87 Hide/Show item
88 ====================================================================
89 */
90 void item_hide( Item *item );
91 void item_show( Item *item );
92 /*
93 ====================================================================
94 Update alpha of item
95 ====================================================================
96 */
97 void item_update_alpha( Item *item, int ms );
98 /*
99 ====================================================================
100 Check if position's on item.
101 ====================================================================
102 */
103 int item_focus( Item *item, int x, int y );
104 
105 #endif
106