[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions , Volume 2


subwin Subroutine

Purpose

Creates a subwindow within an existing window.

Library

Curses Library (libcurses.a)

Syntax

#include <curses.h>
WINDOW *subwin (ParentWindow, NumLines, NumCols,Line,Column)
WINDOW * ParentWindow ;
int NumLines, NumCols, Line, Column;

Description

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.

Parameters


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).

Return Values

When the subwin subroutine is successful, it returns a pointer to the subwindow structure. Otherwise, it returns the following:

ERR Indicates one or more of the parameters is invalid or there is insufficient storage available for the new structure.

Examples

  1. To create a subwindow, use:
    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);

    my_sub_window is now a subwindow 2 lines deep, 5 columns wide, starting at the same coordinates of its parent window my_window. 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 = 34.

  2. To create a subwindow that is flush with the right side of its parent, use:
    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.

  3. To create a subwindow in the lower-right corner of its parent, use:
    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.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The touchwin (touchwin Subroutine), newwin (derwin, newwin, or subwin Subroutine), and wrefresh (refresh or wrefresh Subroutine) subroutines.

Curses Overview for Programming, List of Curses Subroutines, Windows in the Curses Environment in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]