Merge Irssi 0.8.16-rc1
[silc.git] / apps / irssi / src / fe-text / statusbar.h
1 #ifndef __STATUSBAR_H
2 #define __STATUSBAR_H
3
4 #include "mainwindows.h"
5 #include "statusbar-item.h"
6
7 #define STATUSBAR_PRIORITY_HIGH         100
8 #define STATUSBAR_PRIORITY_NORMAL       0
9 #define STATUSBAR_PRIORITY_LOW          -100
10
11 typedef struct SBAR_ITEM_REC SBAR_ITEM_REC;
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 STATUSBAR_GROUP_REC *statusbar_group_create(const char *name);
84 void statusbar_group_destroy(STATUSBAR_GROUP_REC *rec);
85 STATUSBAR_GROUP_REC *statusbar_group_find(const char *name);
86
87 STATUSBAR_REC *statusbar_create(STATUSBAR_GROUP_REC *group,
88                                 STATUSBAR_CONFIG_REC *config,
89                                 MAIN_WINDOW_REC *parent_window);
90 void statusbar_destroy(STATUSBAR_REC *bar);
91 STATUSBAR_REC *statusbar_find(STATUSBAR_GROUP_REC *group, const char *name,
92                               MAIN_WINDOW_REC *window);
93
94 SBAR_ITEM_REC *statusbar_item_create(STATUSBAR_REC *bar,
95                                      SBAR_ITEM_CONFIG_REC *config);
96 void statusbar_item_destroy(SBAR_ITEM_REC *item);
97
98 /* redraw statusbar, NULL = all */
99 void statusbar_redraw(STATUSBAR_REC *bar, int force);
100 void statusbar_item_redraw(SBAR_ITEM_REC *item);
101
102 void statusbar_recreate_items(STATUSBAR_REC *bar);
103 void statusbars_recreate_items(void);
104 void statusbars_create_window_bars(void);
105
106 void statusbar_redraw_dirty(void);
107
108 void statusbar_init(void);
109 void statusbar_deinit(void);
110
111 #endif