blob: 84e29e519c2d15bd61342e7b3a735c105a011ce8 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301------------------------------------------------------------------------------
2-- --
3-- GNAT ncurses Binding --
4-- --
5-- Terminal_Interface.Curses.Panels --
6-- --
7-- B O D Y --
8-- --
9------------------------------------------------------------------------------
Steve Kondikae271bc2015-11-15 02:50:53 +010010-- Copyright (c) 1998-2004,2009 Free Software Foundation, Inc. --
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053011-- --
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, 1996
37-- Version Control:
Steve Kondikae271bc2015-11-15 02:50:53 +010038-- $Revision: 1.14 $
39-- $Date: 2009/12/26 17:38:58 $
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053040-- Binding Version 01.00
41------------------------------------------------------------------------------
42with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
43with Interfaces.C;
44
45package body Terminal_Interface.Curses.Panels is
46
47 use type Interfaces.C.int;
48
49 function Create (Win : Window) return Panel
50 is
51 function Newpanel (Win : Window) return Panel;
52 pragma Import (C, Newpanel, "new_panel");
53
54 Pan : Panel;
55 begin
56 Pan := Newpanel (Win);
57 if Pan = Null_Panel then
58 raise Panel_Exception;
59 end if;
60 return Pan;
61 end Create;
62
Steve Kondikae271bc2015-11-15 02:50:53 +010063 procedure Bottom (Pan : Panel)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053064 is
65 function Bottompanel (Pan : Panel) return C_Int;
66 pragma Import (C, Bottompanel, "bottom_panel");
67 begin
68 if Bottompanel (Pan) = Curses_Err then
69 raise Panel_Exception;
70 end if;
71 end Bottom;
72
Steve Kondikae271bc2015-11-15 02:50:53 +010073 procedure Top (Pan : Panel)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053074 is
75 function Toppanel (Pan : Panel) return C_Int;
76 pragma Import (C, Toppanel, "top_panel");
77 begin
78 if Toppanel (Pan) = Curses_Err then
79 raise Panel_Exception;
80 end if;
81 end Top;
82
Steve Kondikae271bc2015-11-15 02:50:53 +010083 procedure Show (Pan : Panel)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053084 is
85 function Showpanel (Pan : Panel) return C_Int;
86 pragma Import (C, Showpanel, "show_panel");
87 begin
88 if Showpanel (Pan) = Curses_Err then
89 raise Panel_Exception;
90 end if;
91 end Show;
92
Steve Kondikae271bc2015-11-15 02:50:53 +010093 procedure Hide (Pan : Panel)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053094 is
95 function Hidepanel (Pan : Panel) return C_Int;
96 pragma Import (C, Hidepanel, "hide_panel");
97 begin
98 if Hidepanel (Pan) = Curses_Err then
99 raise Panel_Exception;
100 end if;
101 end Hide;
102
103 function Get_Window (Pan : Panel) return Window
104 is
105 function Panel_Win (Pan : Panel) return Window;
106 pragma Import (C, Panel_Win, "panel_window");
107
108 Win : constant Window := Panel_Win (Pan);
109 begin
110 if Win = Null_Window then
111 raise Panel_Exception;
112 end if;
113 return Win;
114 end Get_Window;
115
Steve Kondikae271bc2015-11-15 02:50:53 +0100116 procedure Replace (Pan : Panel;
117 Win : Window)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530118 is
119 function Replace_Pan (Pan : Panel;
120 Win : Window) return C_Int;
121 pragma Import (C, Replace_Pan, "replace_panel");
122 begin
123 if Replace_Pan (Pan, Win) = Curses_Err then
124 raise Panel_Exception;
125 end if;
126 end Replace;
127
Steve Kondikae271bc2015-11-15 02:50:53 +0100128 procedure Move (Pan : Panel;
129 Line : Line_Position;
130 Column : Column_Position)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530131 is
132 function Move (Pan : Panel;
133 Line : C_Int;
134 Column : C_Int) return C_Int;
135 pragma Import (C, Move, "move_panel");
136 begin
137 if Move (Pan, C_Int (Line), C_Int (Column)) = Curses_Err then
138 raise Panel_Exception;
139 end if;
140 end Move;
141
142 function Is_Hidden (Pan : Panel) return Boolean
143 is
144 function Panel_Hidden (Pan : Panel) return C_Int;
145 pragma Import (C, Panel_Hidden, "panel_hidden");
146 begin
147 if Panel_Hidden (Pan) = Curses_False then
148 return False;
149 else
150 return True;
151 end if;
152 end Is_Hidden;
153
154 procedure Delete (Pan : in out Panel)
155 is
156 function Del_Panel (Pan : Panel) return C_Int;
157 pragma Import (C, Del_Panel, "del_panel");
158 begin
159 if Del_Panel (Pan) = Curses_Err then
160 raise Panel_Exception;
161 end if;
162 Pan := Null_Panel;
163 end Delete;
164
165end Terminal_Interface.Curses.Panels;