- Timestamp:
- May 29, 2010, 1:14:57 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.7, release-1.8, release-1.9
- Children:
- 1383b58
- Parents:
- 7c8811c
- git-author:
- David Benjamin <davidben@mit.edu> (05/27/10 02:49:57)
- git-committer:
- David Benjamin <davidben@mit.edu> (05/29/10 13:14:57)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
popwin.c
r0881cdd r68f63a2 11 11 int owl_popwin_up(owl_popwin *pw) 12 12 { 13 int glines, gcols, startcol, startline; 14 WINDOW *popwin, *borderwin; 13 /* make them zero-size for now */ 14 pw->border = owl_window_new(0, 0, 0, 0, 0); 15 pw->content = owl_window_new(pw->border, 0, 0, 0, 0); 15 16 16 /* calculate the size of the popwin */ 17 glines=owl_global_get_lines(&g); 18 gcols=owl_global_get_cols(&g); 17 owl_window_set_redraw_cb(pw->border, owl_popwin_draw_border, pw, 0); 18 owl_window_set_resize_cb(pw->border, owl_popwin_resize_content, pw, 0); 19 /* HACK */ 20 owl_window_set_resize_cb(owl_window_get_screen(), owl_popwin_reposition, pw, 0); 19 21 20 pw->lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2; 21 startline = (glines-pw->lines)/2; 22 /* calculate position, THEN map the windows maybe setting a resize hook 23 * should just cause it to get called? */ 24 owl_popwin_reposition(owl_window_get_screen(), pw); 25 owl_window_map(pw->border, 1); 22 26 23 pw->cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2; 24 startcol = (gcols-pw->cols)/2; 27 pw->active=1; 28 return(0); 29 } 25 30 26 borderwin = newwin(pw->lines, pw->cols, startline, startcol); 27 pw->borderpanel = new_panel(borderwin); 28 popwin = newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1); 29 pw->poppanel = new_panel(popwin); 31 void owl_popwin_reposition(owl_window *screen, void *user_data) 32 { 33 owl_popwin *pw = user_data; 34 int lines, cols, startline, startcol; 35 int glines, gcols; 30 36 31 werase(popwin); 32 werase(borderwin); 37 owl_window_get_position(screen, &glines, &gcols, 0, 0); 38 39 lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2; 40 startline = (glines-lines)/2; 41 cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2; 42 startcol = (gcols-cols)/2; 43 44 owl_window_set_position(pw->border, lines, cols, startline, startcol); 45 } 46 47 void owl_popwin_resize_content(owl_window *w, void *user_data) 48 { 49 owl_popwin *pw = user_data; 50 owl_window_get_position(w, &pw->lines, &pw->cols, 0, 0); 51 owl_window_set_position(pw->content, pw->lines-2, pw->cols-2, 1, 1); 52 } 53 54 void owl_popwin_draw_border(owl_window *w, WINDOW *borderwin, void *user_data) 55 { 56 owl_popwin *pw = user_data; 33 57 if (owl_global_is_fancylines(&g)) { 34 58 box(borderwin, 0, 0); … … 44 68 waddch(borderwin, '+'); 45 69 } 46 47 owl_global_set_needrefresh(&g);48 pw->active=1;49 return(0);50 70 } 51 71 52 72 int owl_popwin_close(owl_popwin *pw) 53 73 { 54 WINDOW *popwin, *borderwin; 55 56 popwin = panel_window(pw->poppanel); 57 borderwin = panel_window(pw->borderpanel); 58 59 del_panel(pw->poppanel); 60 del_panel(pw->borderpanel); 61 delwin(popwin); 62 delwin(borderwin); 63 74 owl_window_delete(pw->border); 75 pw->border = 0; 76 pw->content = 0; 64 77 pw->active=0; 65 owl_ global_set_needrefresh(&g);78 owl_window_set_resize_cb(owl_window_get_screen(), 0, 0, 0); 66 79 return(0); 67 80 } … … 72 85 } 73 86 74 WINDOW *owl_popwin_get_curswin(const owl_popwin *pw)87 owl_window *owl_popwin_get_content(const owl_popwin *pw) 75 88 { 76 return p anel_window(pw->poppanel);89 return pw->content; 77 90 } 78 91
Note: See TracChangeset
for help on using the changeset viewer.