Creates a subwindow within an existing window.
Curses Library (libcurses.a)
#include <curses.h> WINDOW *subwin (ParentWindow, NumLines, NumCols,Line,Column) WINDOW * ParentWindow ; int NumLines, NumCols, Line, Column;
The subwin subroutine creates a subwindow within an existing window. You must supply coordinates for the subwindow relative to the terminal's display. Recall that the subwindow shares its parent's window buffer. Changes made to the shared window buffer in the area covered by a subwindow, through either the parent window or any of its subwindows, affects all windows sharing the window buffer.
When changing the image of a subwindow, it is necessary to call the touchwin (touchwin Subroutine) or touchline subroutine on the parent window before calling the wrefresh (refresh or wrefresh Subroutine) subroutine on the parent window.
Changes to one window will affect the character image of both windows.
Item | Description |
---|---|
NumCols | Indicates the number of vertical columns in the subwindow's width. If 0 is passed as the NumCols value, the subwindow runs from the Column to the right edge of its parent window. |
NumLines | Indicates the number of horizontal lines in the subwindow's height. If 0 is passed as the NumLines parameter, then the subwindow runs from the Line to the bottom of its parent window. |
ParentWindow | Specifies the subwindow's parent. |
Column | Specifies the horizontal coordinate for the upper-left corner
of the subwindow. This coordinate is relative to the (0, 0) coordinates
of the terminal, not the (0, 0) coordinates of the parent window.
Note: The upper-left corner of the terminal is referenced by the
coordinates (0, 0).
|
Line | Specifies the vertical coordinate for the upper-left corner
of the subwindow. This coordinate is relative to the (0, 0) coordinates
of the terminal, not the (0, 0) coordinates of the parent window.
Note: The upper-left corner of the terminal is referenced by the
coordinates (0, 0).
|
When the subwin subroutine is successful, it returns a pointer to the subwindow structure. Otherwise, it returns the following:
Item | Description |
---|---|
ERR | Indicates one or more of the parameters is invalid or there is insufficient storage available for the new structure. |
WINDOW *my_window, *my_sub_window;
my_window = newwin (derwin, newwin, or subwin Subroutine)
(5, 10, 20, 30);
my_sub_window = subwin(my_window, 2, 5, 20, 30);
WINDOW *my_window, *my_sub_window;
my_window = newwin (derwin, newwin, or subwin Subroutine)
(5, 10, 20, 30);
my_sub_window = subwin(my_window, 2, 0, 20, 30);
my_sub_window is now a subwindow 2 lines deep, extending all the way to the right side of its parent window my_window, and starting at the same coordinates. That is, the subwindow's upper-left corner is at coordinates y = 20, x = 30 and lower-right corner is at coordinates y = 21, x = 39.
WINDOW *my_window, *my_sub_window
my_window = newwwin (derwin, newwin, or subwin Subroutine)
(5, 10, 20, 30);
my_sub_window = subwin(my_window, 0, 0, 22, 35);
my_sub_window is now a subwindow that fills the bottom right corner of its parent window, my_window, starting at the coordinates y = 22, x = 35. That is, the subwindow's upper-left corner is at coordinates y = 22, x = 35 and lower-right corner is at coordinates y = 24, x = 39.