]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/ada_include/terminal_interface-curses-panels.adb
ncurses 4.1
[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 --  Version 00.92                                                           --
10 --                                                                          --
11 --  The ncurses Ada95 binding is copyrighted 1996 by                        --
12 --  Juergen Pfeifer, Email: Juergen.Pfeifer@T-Online.de                     --
13 --                                                                          --
14 --  Permission is hereby granted to reproduce and distribute this           --
15 --  binding by any means and for any fee, whether alone or as part          --
16 --  of a larger distribution, in source or in binary form, PROVIDED         --
17 --  this notice is included with any such distribution, and is not          --
18 --  removed from any of its header files. Mention of ncurses and the        --
19 --  author of this binding in any applications linked with it is            --
20 --  highly appreciated.                                                     --
21 --                                                                          --
22 --  This binding comes AS IS with no warranty, implied or expressed.        --
23 ------------------------------------------------------------------------------
24 --  Version Control:
25 --  $Revision: 1.3 $
26 ------------------------------------------------------------------------------
27 with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
28 with Interfaces.C;
29
30 package body Terminal_Interface.Curses.Panels is
31
32    use type Interfaces.C.int;
33
34    function Create (Win : Window) return Panel
35    is
36       function Newpanel (Win : Window) return Panel;
37       pragma Import (C, Newpanel, "new_panel");
38
39       Pan : Panel;
40    begin
41       Pan := Newpanel (Win);
42       if Pan = Null_Panel then
43          raise Panel_Exception;
44       end if;
45       return Pan;
46    end Create;
47
48    procedure Bottom (Pan : in Panel)
49    is
50       function Bottompanel (Pan : Panel) return C_Int;
51       pragma Import (C, Bottompanel, "bottom_panel");
52    begin
53       if Bottompanel (Pan) = Curses_Err then
54          raise Panel_Exception;
55       end if;
56    end Bottom;
57
58    procedure Top (Pan : in Panel)
59    is
60       function Toppanel (Pan : Panel) return C_Int;
61       pragma Import (C, Toppanel, "top_panel");
62    begin
63       if Toppanel (Pan) = Curses_Err then
64          raise Panel_Exception;
65       end if;
66    end Top;
67
68    procedure Show (Pan : in Panel)
69    is
70       function Showpanel (Pan : Panel) return C_Int;
71       pragma Import (C, Showpanel, "show_panel");
72    begin
73       if Showpanel (Pan) = Curses_Err then
74          raise Panel_Exception;
75       end if;
76    end Show;
77
78    procedure Hide (Pan : in Panel)
79    is
80       function Hidepanel (Pan : Panel) return C_Int;
81       pragma Import (C, Hidepanel, "hide_panel");
82    begin
83       if Hidepanel (Pan) = Curses_Err then
84          raise Panel_Exception;
85       end if;
86    end Hide;
87
88    function Get_Window (Pan : Panel) return Window
89    is
90       function Panel_Win (Pan : Panel) return Window;
91       pragma Import (C, Panel_Win, "panel_window");
92
93       Win : Window := Panel_Win (Pan);
94    begin
95       if Win = Null_Window then
96          raise Panel_Exception;
97       end if;
98       return Win;
99    end Get_Window;
100
101    procedure Replace (Pan : in Panel;
102                       Win : in Window)
103    is
104       function Replace_Pan (Pan : Panel;
105                             Win : Window) return C_Int;
106       pragma Import (C, Replace_Pan, "replace_panel");
107    begin
108       if Replace_Pan (Pan, Win) = Curses_Err then
109          raise Panel_Exception;
110       end if;
111    end Replace;
112
113    procedure Move (Pan    : in Panel;
114                    Line   : in Line_Position;
115                    Column : in Column_Position)
116    is
117       function Move (Pan    : Panel;
118                      Line   : C_Int;
119                      Column : C_Int) return C_Int;
120       pragma Import (C, Move, "move_panel");
121    begin
122       if Move (Pan, C_Int (Line), C_Int (Column)) = Curses_Err then
123          raise Panel_Exception;
124       end if;
125    end Move;
126
127    function Is_Hidden (Pan : Panel) return Boolean
128    is
129       function Panel_Hidden (Pan : Panel) return C_Int;
130       pragma Import (C, Panel_Hidden, "panel_hidden");
131    begin
132       if Panel_Hidden (Pan) = Curses_False then
133          return False;
134       else
135          return True;
136       end if;
137    end Is_Hidden;
138
139    procedure Delete (Pan : in out Panel)
140    is
141       function Del_Panel (Pan : Panel) return C_Int;
142       pragma Import (C, Del_Panel, "del_panel");
143    begin
144       if Del_Panel (Pan) = Curses_Err then
145          raise Panel_Exception;
146       end if;
147       Pan := Null_Panel;
148    end Delete;
149
150 end Terminal_Interface.Curses.Panels;