Added SILC Thread Queue API
[crypto.git] / apps / irssi / src / fe-text / statusbar.h
1 #ifndef __STATUSBAR_H
2 #define __STATUSBAR_H
3
4 #include "mainwindows.h"
5
6 #define STATUSBAR_PRIORITY_HIGH         100
7 #define STATUSBAR_PRIORITY_NORMAL       0
8 #define STATUSBAR_PRIORITY_LOW          -100
9
10 typedef struct SBAR_ITEM_REC SBAR_ITEM_REC;
11 typedef void (*STATUSBAR_FUNC) (SBAR_ITEM_REC *item, int get_size_only);
12
13 /* type */
14 #define STATUSBAR_TYPE_ROOT     1
15 #define STATUSBAR_TYPE_WINDOW   2
16
17 /* placement */
18 #define STATUSBAR_TOP           1
19 #define STATUSBAR_BOTTOM        2
20
21 /* visible */
22 #define STATUSBAR_VISIBLE_ALWAYS        1
23 #define STATUSBAR_VISIBLE_ACTIVE        2
24 #define STATUSBAR_VISIBLE_INACTIVE      3
25
26 typedef struct {
27         char *name;
28         GSList *config_bars;
29         GSList *bars;
30 } STATUSBAR_GROUP_REC;
31
32 typedef struct {
33         char *name;
34
35         int type; /* root/window */
36         int placement; /* top/bottom */
37         int position; /* the higher the number, the lower it is in screen */
38         int visible; /* active/inactive/always */
39
40         GSList *items;
41 } STATUSBAR_CONFIG_REC;
42
43 typedef struct {
44         STATUSBAR_GROUP_REC *group;
45         STATUSBAR_CONFIG_REC *config;
46
47         MAIN_WINDOW_REC *parent_window; /* if config->type == STATUSBAR_TYPE_WINDOW */
48         GSList *items;
49
50         char *color; /* background color */
51         int real_ypos; /* real Y-position in screen at the moment */
52
53         unsigned int dirty:1;
54         int dirty_xpos; /* -1 = only redraw some items, >= 0 = redraw all items after from xpos */
55 } STATUSBAR_REC;
56
57 typedef struct {
58         char *name;
59         char *value; /* if non-NULL, overrides the default */
60
61         int priority;
62         unsigned int right_alignment:1;
63 } SBAR_ITEM_CONFIG_REC;
64
65 struct SBAR_ITEM_REC {
66         STATUSBAR_REC *bar;
67         SBAR_ITEM_CONFIG_REC *config;
68         STATUSBAR_FUNC func;
69
70         /* what item wants */
71         int min_size, max_size;
72
73         /* what item gets */
74         int xpos, size;
75
76         int current_size; /* item size currently in screen */
77         unsigned int dirty:1;
78 };
79
80 extern GSList *statusbar_groups;
81 extern STATUSBAR_GROUP_REC *active_statusbar_group;
82
83 void statusbar_item_register(const char *name, const char *value,
84                              STATUSBAR_FUNC func);
85 void statusbar_item_unregister(const char *name);
86
87 STATUSBAR_GROUP_REC *statusbar_group_create(const char *name);
88 void statusbar_group_destroy(STATUSBAR_GROUP_REC *rec);
89 STATUSBAR_GROUP_REC *statusbar_group_find(const char *name);
90
91 STATUSBAR_REC *statusbar_create(STATUSBAR_GROUP_REC *group,
92                                 STATUSBAR_CONFIG_REC *config,
93                                 MAIN_WINDOW_REC *parent_window);
94 void statusbar_destroy(STATUSBAR_REC *bar);
95 STATUSBAR_REC *statusbar_find(STATUSBAR_GROUP_REC *group, const char *name,
96                               MAIN_WINDOW_REC *window);
97
98 SBAR_ITEM_REC *statusbar_item_create(STATUSBAR_REC *bar,
99                                      SBAR_ITEM_CONFIG_REC *config);
100 void statusbar_item_destroy(SBAR_ITEM_REC *item);
101
102 void statusbar_item_default_handler(SBAR_ITEM_REC *item, int get_size_only,
103                                     const char *str, const char *data,
104                                     int escape_vars);
105
106 /* redraw statusbar, NULL = all */
107 void statusbar_redraw(STATUSBAR_REC *bar, int force);
108 void statusbar_item_redraw(SBAR_ITEM_REC *item);
109 void statusbar_items_redraw(const char *name);
110
111 void statusbar_recreate_items(STATUSBAR_REC *bar);
112 void statusbars_recreate_items(void);
113 void statusbars_create_window_bars(void);
114
115 void statusbar_redraw_dirty(void);
116
117 void statusbar_init(void);
118 void statusbar_deinit(void);
119
120 #endif