libt3window
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules
window.h
1 /* Copyright (C) 2011 G.P. Halkes
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License version 3, as
4  published by the Free Software Foundation.
5 
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10 
11  You should have received a copy of the GNU General Public License
12  along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14 #ifndef T3_WINDOW_H
15 #define T3_WINDOW_H
16 
19 #include <stdlib.h>
20 #include <t3window/terminal.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
27 #define T3_PARENT(_x) ((_x) << 4)
28 
29 #define T3_CHILD(_x) ((_x) << 8)
30 
31 #define T3_GETPARENT(_x) (((_x) >> 4) & 0xf)
32 
33 #define T3_GETCHILD(_x) (((_x) >> 8) & 0xf)
34 
44  T3_ANCHOR_TOPLEFT,
45  T3_ANCHOR_TOPRIGHT,
46  T3_ANCHOR_BOTTOMLEFT,
47  T3_ANCHOR_BOTTOMRIGHT,
48  T3_ANCHOR_CENTER,
49  T3_ANCHOR_TOPCENTER,
50  T3_ANCHOR_BOTTOMCENTER,
51  T3_ANCHOR_CENTERLEFT,
52  T3_ANCHOR_CENTERRIGHT
53 };
54 
58 typedef struct t3_window_t t3_window_t;
59 
60 T3_WINDOW_API t3_window_t *t3_win_new(t3_window_t *parent, int height, int width, int y, int x, int depth);
61 T3_WINDOW_API t3_window_t *t3_win_new_unbacked(t3_window_t *parent, int height, int width, int y, int x, int depth);
62 T3_WINDOW_API void t3_win_del(t3_window_t *win);
63 
64 T3_WINDOW_API t3_bool t3_win_set_parent(t3_window_t *win, t3_window_t *parent);
65 T3_WINDOW_API t3_bool t3_win_set_anchor(t3_window_t *win, t3_window_t *anchor, int relation);
66 T3_WINDOW_API void t3_win_set_depth(t3_window_t *win, int depth);
67 T3_WINDOW_API void t3_win_set_default_attrs(t3_window_t *win, t3_attr_t attr);
68 T3_WINDOW_API t3_bool t3_win_set_restrict(t3_window_t *win, t3_window_t *restrict);
69 
70 T3_WINDOW_API t3_bool t3_win_resize(t3_window_t *win, int height, int width);
71 T3_WINDOW_API void t3_win_move(t3_window_t *win, int y, int x);
72 T3_WINDOW_API int t3_win_get_width(t3_window_t *win);
73 T3_WINDOW_API int t3_win_get_height(t3_window_t *win);
74 T3_WINDOW_API int t3_win_get_x(t3_window_t *win);
75 T3_WINDOW_API int t3_win_get_y(t3_window_t *win);
76 T3_WINDOW_API int t3_win_get_abs_x(t3_window_t *win);
77 T3_WINDOW_API int t3_win_get_abs_y(t3_window_t *win);
78 T3_WINDOW_API int t3_win_get_depth(t3_window_t *win);
79 T3_WINDOW_API int t3_win_get_relation(t3_window_t *win, t3_window_t **anchor);
80 T3_WINDOW_API t3_window_t *t3_win_get_parent(t3_window_t *win);
81 T3_WINDOW_API void t3_win_set_cursor(t3_window_t *win, int y, int x);
82 T3_WINDOW_API void t3_win_set_paint(t3_window_t *win, int y, int x);
83 T3_WINDOW_API void t3_win_show(t3_window_t *win);
84 T3_WINDOW_API void t3_win_hide(t3_window_t *win);
85 
86 T3_WINDOW_API int t3_win_addnstr(t3_window_t *win, const char *str, size_t n, t3_attr_t attr);
87 T3_WINDOW_API int t3_win_addstr(t3_window_t *win, const char *str, t3_attr_t attr);
88 T3_WINDOW_API int t3_win_addch(t3_window_t *win, char c, t3_attr_t attr);
89 
90 T3_WINDOW_API int t3_win_addnstrrep(t3_window_t *win, const char *str, size_t n, t3_attr_t attr, int rep);
91 T3_WINDOW_API int t3_win_addstrrep(t3_window_t *win, const char *str, t3_attr_t attr, int rep);
92 T3_WINDOW_API int t3_win_addchrep(t3_window_t *win, char c, t3_attr_t attr, int rep);
93 
94 T3_WINDOW_API int t3_win_box(t3_window_t *win, int y, int x, int height, int width, t3_attr_t attr);
95 
96 T3_WINDOW_API void t3_win_clrtoeol(t3_window_t *win);
97 T3_WINDOW_API void t3_win_clrtobot(t3_window_t *win);
98 
99 T3_WINDOW_API t3_window_t *t3_win_at_location(int search_y, int search_x);
100 #ifdef __cplusplus
101 } /* extern "C" */
102 #endif
103 
104 #endif
int t3_win_get_width(t3_window_t *win)
Get a t3_window_t's width.
Definition: window.c:419
int t3_win_addstr(t3_window_t *win, const char *str, t3_attr_t attr)
Add a nul-terminated string to a t3_window_t with specified attributes.
Definition: window_paint.c:655
int t3_win_addnstrrep(t3_window_t *win, const char *str, size_t n, t3_attr_t attr, int rep)
Add a string with explicitly specified size to a t3_window_t with specified attributes and repetition...
Definition: window_paint.c:678
int t3_win_get_abs_y(t3_window_t *win)
Get a t3_window_t's absolute vertical position.
Definition: window.c:530
t3_window_t * t3_win_new_unbacked(t3_window_t *parent, int height, int width, int y, int x, int depth)
Create a new t3_window_t with relative position without backing store.
Definition: window.c:161
int t3_win_addstrrep(t3_window_t *win, const char *str, t3_attr_t attr, int rep)
Add a nul-terminated string to a t3_window_t with specified attributes and repetition.
Definition: window_paint.c:698
char t3_bool
A boolean type that does not clash with C++ or C99 bool.
Definition: window_api.h:47
void t3_win_show(t3_window_t *win)
Make a t3_window_t visible.
Definition: window.c:604
int t3_win_get_abs_x(t3_window_t *win)
Get a t3_window_t's absolute horizontal position.
Definition: window.c:473
void t3_win_clrtoeol(t3_window_t *win)
Clear current t3_window_t painting line to end.
Definition: window_paint.c:918
int t3_win_addch(t3_window_t *win, char c, t3_attr_t attr)
Add a single character to a t3_window_t with specified attributes.
Definition: window_paint.c:665
void t3_win_set_depth(t3_window_t *win, int depth)
Change the depth of a t3_window_t.
Definition: window.c:254
t3_bool t3_win_resize(t3_window_t *win, int height, int width)
Change a t3_window_t's size.
Definition: window.c:354
An opaque struct representing a window which can be shown on the terminal.
Definition: internal.h:47
int t3_win_get_height(t3_window_t *win)
Get a t3_window_t's height.
Definition: window.c:424
void t3_win_del(t3_window_t *win)
Discard a t3_window_t.
Definition: window.c:325
t3_win_anchor_t
Anchor points for defining relations between the positions of two windows.
Definition: window.h:43
void t3_win_clrtobot(t3_window_t *win)
Clear current t3_window_t painting line to end and all subsequent lines fully.
Definition: window_paint.c:996
void t3_win_set_cursor(t3_window_t *win, int y, int x)
Position the cursor relative to a t3_window_t.
Definition: window.c:592
int t3_win_addnstr(t3_window_t *win, const char *str, size_t n, t3_attr_t attr)
Add a string with explicitly specified size to a t3_window_t with specified attributes.
Definition: window_paint.c:604
void t3_win_move(t3_window_t *win, int y, int x)
Change a t3_window_t's position.
Definition: window.c:413
t3_bool t3_win_set_anchor(t3_window_t *win, t3_window_t *anchor, int relation)
Link a t3_window_t's position to the position of another t3_window_t.
Definition: window.c:222
void t3_win_hide(t3_window_t *win)
Make a t3_window_t invisible.
Definition: window.c:609
int t3_win_get_x(t3_window_t *win)
Get a t3_window_t's horizontal position.
Definition: window.c:433
int t3_win_addchrep(t3_window_t *win, char c, t3_attr_t attr, int rep)
Add a character to a t3_window_t with specified attributes and repetition.
Definition: window_paint.c:711
int t3_win_get_depth(t3_window_t *win)
Get a t3_window_t's depth.
Definition: window.c:448
t3_bool t3_win_set_parent(t3_window_t *win, t3_window_t *parent)
Change a t3_window_t's parent.
Definition: window.c:192
t3_window_t * t3_win_at_location(int search_y, int search_x)
Find the top-most window at a location.
Definition: window_paint.c:1012
t3_window_t * t3_win_get_parent(t3_window_t *win)
Get a t3_window_t's parent window.
Definition: window.c:468
t3_bool t3_win_set_restrict(t3_window_t *win, t3_window_t *restrict)
Set the restrictw window.
Definition: window.c:293
int t3_win_box(t3_window_t *win, int y, int x, int height, int width, t3_attr_t attr)
Draw a box on a t3_window_t.
Definition: window_paint.c:969
int t3_win_get_relation(t3_window_t *win, t3_window_t **anchor)
Get a t3_window_t's relative positioning information.
Definition: window.c:461
t3_window_t * t3_win_new(t3_window_t *parent, int height, int width, int y, int x, int depth)
Create a new t3_window_t.
Definition: window.c:122
int t3_win_get_y(t3_window_t *win)
Get a t3_window_t's vertical position.
Definition: window.c:443
void t3_win_set_default_attrs(t3_window_t *win, t3_attr_t attr)
Set default attributes for a window.
Definition: window.c:279
void t3_win_set_paint(t3_window_t *win, int y, int x)
Change the position where characters are written to the t3_window_t.
Definition: window.c:598
long t3_attr_t
Type to hold attributes used for terminal display.
Definition: terminal.h:63