source: popwin.c @ 402ed3d3

release-1.7release-1.8release-1.9
Last change on this file since 402ed3d3 was 402ed3d3, checked in by David Benjamin <davidben@mit.edu>, 12 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
RevLine 
[7d4fbcd]1#include "owl.h"
2
[b2b0773]3int owl_popwin_init(owl_popwin *pw)
4{
[7d4fbcd]5  pw->active=0;
6  return(0);
7}
8
[b2b0773]9int owl_popwin_up(owl_popwin *pw)
10{
[d106110]11  pw->border = owl_window_new(NULL);
12  pw->content = owl_window_new(pw->border);
[68f63a2]13  owl_window_set_redraw_cb(pw->border, owl_popwin_draw_border, pw, 0);
[d106110]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);
[402ed3d3]16  owl_window_show_all(pw->border);
[fe67f1f]17
[68f63a2]18  pw->active=1;
19  return(0);
20}
21
[d106110]22void owl_popwin_size_border(owl_window *border, void *user_data)
[68f63a2]23{
24  int lines, cols, startline, startcol;
25  int glines, gcols;
[d106110]26  owl_window *parent = owl_window_get_parent(border);
[7d4fbcd]27
[d106110]28  owl_window_get_position(parent, &glines, &gcols, 0, 0);
[7d4fbcd]29
[68f63a2]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
[d106110]35  owl_window_set_position(border, lines, cols, startline, startcol);
[68f63a2]36}
37
[d106110]38void owl_popwin_size_content(owl_window *content, void *user_data)
[68f63a2]39{
[d3814ff]40  int lines, cols;
[d106110]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);
[68f63a2]44}
45
46void owl_popwin_draw_border(owl_window *w, WINDOW *borderwin, void *user_data)
47{
[1383b58]48  int lines, cols;
49  owl_window_get_position(w, &lines, &cols, 0, 0);
[c15bbfb]50  if (owl_global_is_fancylines(&g)) {
[dffb8b8]51    box(borderwin, 0, 0);
[c15bbfb]52  } else {
[dffb8b8]53    box(borderwin, '|', '-');
54    wmove(borderwin, 0, 0);
55    waddch(borderwin, '+');
[1383b58]56    wmove(borderwin, lines-1, 0);
[dffb8b8]57    waddch(borderwin, '+');
[1383b58]58    wmove(borderwin, lines-1, cols-1);
[dffb8b8]59    waddch(borderwin, '+');
[1383b58]60    wmove(borderwin, 0, cols-1);
[dffb8b8]61    waddch(borderwin, '+');
[c15bbfb]62  }
[7d4fbcd]63}
64
[b2b0773]65int owl_popwin_close(owl_popwin *pw)
66{
[68f63a2]67  owl_window_delete(pw->border);
68  pw->border = 0;
69  pw->content = 0;
[7d4fbcd]70  pw->active=0;
71  return(0);
72}
73
[9c01a5e]74int owl_popwin_is_active(const owl_popwin *pw)
[b2b0773]75{
[06cc8d9]76  return pw->active;
[7d4fbcd]77}
78
[68f63a2]79owl_window *owl_popwin_get_content(const owl_popwin *pw)
[b2b0773]80{
[68f63a2]81  return pw->content;
[7d4fbcd]82}
Note: See TracBrowser for help on using the repository browser.