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