1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
/*
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* gui-curses-panel.c: panel functions for Curses GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../protocols/irc/irc.h"
#include "gui-curses.h"
/*
* gui_panel_windows_get_size: get total panel size (window panels) for a position
* panel is optional, if not NULL, size is computed
* from panel 1 to panel # - 1
*/
int
gui_panel_window_get_size (t_gui_panel *panel, t_gui_window *window, int position)
{
t_gui_panel_window *ptr_panel_win;
int total_size;
total_size = 0;
for (ptr_panel_win = GUI_CURSES(window)->panel_windows; ptr_panel_win;
ptr_panel_win = ptr_panel_win->next_panel_window)
{
/* stop before panel */
if ((panel) && (ptr_panel_win->panel == panel))
return total_size;
if (ptr_panel_win->panel->position == position)
{
switch (position)
{
case GUI_PANEL_TOP:
case GUI_PANEL_BOTTOM:
total_size += ptr_panel_win->height;
break;
case GUI_PANEL_LEFT:
case GUI_PANEL_RIGHT:
total_size += ptr_panel_win->width;
break;
}
if (ptr_panel_win->panel->separator)
total_size++;
}
}
return total_size;
}
/*
* gui_panel_window_new: create a new "window panel" for a panel, in screen or a window
* if window is not NULL, panel window will be in this window
*/
int
gui_panel_window_new (t_gui_panel *panel, t_gui_window *window)
{
t_gui_panel_window *new_panel_win;
int x1, y1, x2, y2;
int add_top, add_bottom, add_left, add_right;
if (window)
{
x1 = window->win_x;
y1 = window->win_y + 1;
x2 = x1 + window->win_width - 1;
y2 = y1 + window->win_height - 1 - 4;
add_left = gui_panel_window_get_size (panel, window, GUI_PANEL_LEFT);
add_right = gui_panel_window_get_size (panel, window, GUI_PANEL_RIGHT);
add_top = gui_panel_window_get_size (panel, window, GUI_PANEL_TOP);
add_bottom = gui_panel_window_get_size (panel, window, GUI_PANEL_BOTTOM);
}
else
{
x1 = 0;
y1 = 0;
x2 = gui_window_get_width () - 1;
y2 = gui_window_get_height () - 1;
add_left = gui_panel_global_get_size (panel, GUI_PANEL_LEFT);
add_right = gui_panel_global_get_size (panel, GUI_PANEL_RIGHT);
add_top = gui_panel_global_get_size (panel, GUI_PANEL_TOP);
add_bottom = gui_panel_global_get_size (panel, GUI_PANEL_BOTTOM);
}
if ((new_panel_win = (t_gui_panel_window *) malloc (sizeof (t_gui_panel_window))))
{
new_panel_win->panel = panel;
if (window)
{
panel->panel_window = NULL;
new_panel_win->next_panel_window = GUI_CURSES(window)->panel_windows;
GUI_CURSES(window)->panel_windows = new_panel_win;
}
else
{
panel->panel_window = new_panel_win;
new_panel_win->next_panel_window = NULL;
}
switch (panel->position)
{
case GUI_PANEL_TOP:
new_panel_win->x = x1 + add_left;
new_panel_win->y = y1 + add_top;
new_panel_win->width = x2 - x1 + 1;
new_panel_win->height = panel->size;
break;
case GUI_PANEL_BOTTOM:
new_panel_win->x = x1;
new_panel_win->y = y2 - panel->size + 1;
new_panel_win->width = x2 - x1 + 1;
new_panel_win->height = panel->size;
break;
case GUI_PANEL_LEFT:
new_panel_win->x = x1;
new_panel_win->y = y1;
new_panel_win->width = panel->size;
new_panel_win->height = y2 - y1 + 1;
break;
case GUI_PANEL_RIGHT:
new_panel_win->x = x2 - panel->size + 1;
new_panel_win->y = y1;
new_panel_win->width = panel->size;
new_panel_win->height = y2 - y1 + 1;
break;
}
new_panel_win->win_panel = newwin (new_panel_win->height,
new_panel_win->width,
new_panel_win->y,
new_panel_win->x);
new_panel_win->win_separator = NULL;
if (new_panel_win->panel->separator)
{
switch (panel->position)
{
case GUI_PANEL_LEFT:
new_panel_win->win_separator = newwin (new_panel_win->height,
1,
new_panel_win->y,
new_panel_win->x + new_panel_win->width);
break;
}
}
return 1;
}
else
return 0;
}
/*
* gui_panel_window_free: delete a panel window
*/
void
gui_panel_window_free (void *panel_win)
{
t_gui_panel_window *ptr_panel_win;
ptr_panel_win = (t_gui_panel_window *)panel_win;
free (ptr_panel_win);
}
/*
* gui_panel_redraw_buffer: redraw panels for windows displaying a buffer
*/
void
gui_panel_redraw_buffer (t_gui_buffer *buffer)
{
t_gui_window *ptr_win;
t_gui_panel_window *ptr_panel_win;
if (!gui_ok)
return;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if ((ptr_win->buffer == buffer) && (buffer->num_displayed > 0))
{
for (ptr_panel_win = GUI_CURSES(ptr_win)->panel_windows;
ptr_panel_win;
ptr_panel_win = ptr_panel_win->next_panel_window)
{
switch (ptr_panel_win->panel->position)
{
case GUI_PANEL_LEFT:
break;
}
}
}
}
}
|