]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/ada_include/terminal_interface-curses-panels.adb
ncurses 4.2
[ncurses.git] / Ada95 / ada_include / terminal_interface-curses-panels.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                           GNAT ncurses Binding                           --
4 --                                                                          --
5 --                      Terminal_Interface.Curses.Panels                    --
6 --                                                                          --
7 --                                 B O D Y                                  --
8 --                                                                          --
9 ------------------------------------------------------------------------------
10 -- Copyright (c) 1998 Free Software Foundation, Inc.                        --
11 --                                                                          --
12 -- Permission is hereby granted, free of charge, to any person obtaining a  --
13 -- copy of this software and associated documentation files (the            --
14 -- "Software"), to deal in the Software without restriction, including      --
15 -- without limitation the rights to use, copy, modify, merge, publish,      --
16 -- distribute, distribute with modifications, sublicense, and/or sell       --
17 -- copies of the Software, and to permit persons to whom the Software is    --
18 -- furnished to do so, subject to the following conditions:                 --
19 --                                                                          --
20 -- The above copyright notice and this permission notice shall be included  --
21 -- in all copies or substantial portions of the Software.                   --
22 --                                                                          --
23 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  --
24 -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               --
25 -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   --
26 -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   --
27 -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    --
28 -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    --
29 -- THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               --
30 --                                                                          --
31 -- Except as contained in this notice, the name(s) of the above copyright   --
32 -- holders shall not be used in advertising or otherwise to promote the     --
33 -- sale, use or other dealings in this Software without prior written       --
34 -- authorization.                                                           --
35 ------------------------------------------------------------------------------
36 --  Author: Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> 1996
37 --  Version Control:
38 --  $Revision: 1.6 $
39 --  Binding Version 00.93
40 ------------------------------------------------------------------------------
41 with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
42 with Interfaces.C;
43
44 package body Terminal_Interface.Curses.Panels is
45
46    use type Interfaces.C.int;
47
48    function Create (Win : Window) return Panel
49    is
50       function Newpanel (Win : Window) return Panel;
51       pragma Import (C, Newpanel, "new_panel");
52
53       Pan : Panel;
54    begin
55       Pan := Newpanel (Win);
56       if Pan = Null_Panel then
57          raise Panel_Exception;
58       end if;
59       return Pan;
60    end Create;
61
62    procedure Bottom (Pan : in Panel)
63    is
64       function Bottompanel (Pan : Panel) return C_Int;
65       pragma Import (C, Bottompanel, "bottom_panel");
66    begin
67       if Bottompanel (Pan) = Curses_Err then
68          raise Panel_Exception;
69       end if;
70    end Bottom;
71
72    procedure Top (Pan : in Panel)
73    is
74       function Toppanel (Pan : Panel) return C_Int;
75       pragma Import (C, Toppanel, "top_panel");
76    begin
77       if Toppanel (Pan) = Curses_Err then
78          raise Panel_Exception;
79       end if;
80    end Top;
81
82    procedure Show (Pan : in Panel)
83    is
84       function Showpanel (Pan : Panel) return C_Int;
85       pragma Import (C, Showpanel, "show_panel");
86    begin
87       if Showpanel (Pan) = Curses_Err then
88          raise Panel_Exception;
89       end if;
90    end Show;
91
92    procedure Hide (Pan : in Panel)
93    is
94       function Hidepanel (Pan : Panel) return C_Int;
95       pragma Import (C, Hidepanel, "hide_panel");
96    begin
97       if Hidepanel (Pan) = Curses_Err then
98          raise Panel_Exception;
99       end if;
100    end Hide;
101
102    function Get_Window (Pan : Panel) return Window
103    is
104       function Panel_Win (Pan : Panel) return Window;
105       pragma Import (C, Panel_Win, "panel_window");
106
107       Win : Window := Panel_Win (Pan);
108    begin
109       if Win = Null_Window then
110          raise Panel_Exception;
111       end if;
112       return Win;
113    end Get_Window;
114
115    procedure Replace (Pan : in Panel;
116                       Win : in Window)
117    is
118       function Replace_Pan (Pan : Panel;
119                             Win : Window) return C_Int;
120       pragma Import (C, Replace_Pan, "replace_panel");
121    begin
122       if Replace_Pan (Pan, Win) = Curses_Err then
123          raise Panel_Exception;
124       end if;
125    end Replace;
126
127    procedure Move (Pan    : in Panel;
128                    Line   : in Line_Position;
129                    Column : in Column_Position)
130    is
131       function Move (Pan    : Panel;
132                      Line   : C_Int;
133                      Column : C_Int) return C_Int;
134       pragma Import (C, Move, "move_panel");
135    begin
136       if Move (Pan, C_Int (Line), C_Int (Column)) = Curses_Err then
137          raise Panel_Exception;
138       end if;
139    end Move;
140
141    function Is_Hidden (Pan : Panel) return Boolean
142    is
143       function Panel_Hidden (Pan : Panel) return C_Int;
144       pragma Import (C, Panel_Hidden, "panel_hidden");
145    begin
146       if Panel_Hidden (Pan) = Curses_False then
147          return False;
148       else
149          return True;
150       end if;
151    end Is_Hidden;
152
153    procedure Delete (Pan : in out Panel)
154    is
155       function Del_Panel (Pan : Panel) return C_Int;
156       pragma Import (C, Del_Panel, "del_panel");
157    begin
158       if Del_Panel (Pan) = Curses_Err then
159          raise Panel_Exception;
160       end if;
161       Pan := Null_Panel;
162    end Delete;
163
164 end Terminal_Interface.Curses.Panels;