source: popwin.c @ 402ed3d3

release-1.10release-1.7release-1.8release-1.9
Last change on this file since 402ed3d3 was 402ed3d3, checked in by David Benjamin <davidben@mit.edu>, 14 years ago
Use two functions: show/show_all instead of recurse flag It's more readable, and matches GTK.
  • Property mode set to 100644
File size: 2.0 KB
Line 
1#include "owl.h"
2
3int owl_popwin_init(owl_popwin *pw)
4{
5  pw->active=0;
6  return(0);
7}
8
9int owl_popwin_up(owl_popwin *pw)
10{
11  pw->border = owl_window_new(NULL);
12  pw->content = owl_window_new(pw->border);
13  owl_window_set_redraw_cb(pw->border, owl_popwin_draw_border, pw, 0);
14  owl_window_set_size_cb(pw->border, owl_popwin_size_border, 0, 0);
15  owl_window_set_size_cb(pw->content, owl_popwin_size_content, 0, 0);
16  owl_window_show_all(pw->border);
17
18  pw->active=1;
19  return(0);
20}
21
22void owl_popwin_size_border(owl_window *border, void *user_data)
23{
24  int lines, cols, startline, startcol;
25  int glines, gcols;
26  owl_window *parent = owl_window_get_parent(border);
27
28  owl_window_get_position(parent, &glines, &gcols, 0, 0);
29
30  lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2;
31  startline = (glines-lines)/2;
32  cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2;
33  startcol = (gcols-cols)/2;
34
35  owl_window_set_position(border, lines, cols, startline, startcol);
36}
37
38void owl_popwin_size_content(owl_window *content, void *user_data)
39{
40  int lines, cols;
41  owl_window *parent = owl_window_get_parent(content);
42  owl_window_get_position(parent, &lines, &cols, 0, 0);
43  owl_window_set_position(content, lines-2, cols-2, 1, 1);
44}
45
46void owl_popwin_draw_border(owl_window *w, WINDOW *borderwin, void *user_data)
47{
48  int lines, cols;
49  owl_window_get_position(w, &lines, &cols, 0, 0);
50  if (owl_global_is_fancylines(&g)) {
51    box(borderwin, 0, 0);
52  } else {
53    box(borderwin, '|', '-');
54    wmove(borderwin, 0, 0);
55    waddch(borderwin, '+');
56    wmove(borderwin, lines-1, 0);
57    waddch(borderwin, '+');
58    wmove(borderwin, lines-1, cols-1);
59    waddch(borderwin, '+');
60    wmove(borderwin, 0, cols-1);
61    waddch(borderwin, '+');
62  }
63}
64
65int owl_popwin_close(owl_popwin *pw)
66{
67  owl_window_delete(pw->border);
68  pw->border = 0;
69  pw->content = 0;
70  pw->active=0;
71  return(0);
72}
73
74int owl_popwin_is_active(const owl_popwin *pw)
75{
76  return pw->active;
77}
78
79owl_window *owl_popwin_get_content(const owl_popwin *pw)
80{
81  return pw->content;
82}
Note: See TracBrowser for help on using the repository browser.