2 define(`HTMLNAME',`terminal_interface-curses-menus__ads.htm')dnl
4 ------------------------------------------------------------------------------
6 -- GNAT ncurses Binding --
8 -- Terminal_Interface.Curses.Menu --
12 ------------------------------------------------------------------------------
13 -- Copyright (c) 1998-2007,2009 Free Software Foundation, Inc. --
15 -- Permission is hereby granted, free of charge, to any person obtaining a --
16 -- copy of this software and associated documentation files (the --
17 -- "Software"), to deal in the Software without restriction, including --
18 -- without limitation the rights to use, copy, modify, merge, publish, --
19 -- distribute, distribute with modifications, sublicense, and/or sell --
20 -- copies of the Software, and to permit persons to whom the Software is --
21 -- furnished to do so, subject to the following conditions: --
23 -- The above copyright notice and this permission notice shall be included --
24 -- in all copies or substantial portions of the Software. --
26 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
27 -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
28 -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
29 -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
30 -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
31 -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
32 -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
34 -- Except as contained in this notice, the name(s) of the above copyright --
35 -- holders shall not be used in advertising or otherwise to promote the --
36 -- sale, use or other dealings in this Software without prior written --
38 ------------------------------------------------------------------------------
39 -- Author: Juergen Pfeifer, 1996
42 -- $Date: 2009/12/26 18:35:22 $
43 -- Binding Version 01.00
44 ------------------------------------------------------------------------------
45 include(`Menu_Base_Defs')
47 with Ada.Characters.Latin_1;
49 package Terminal_Interface.Curses.Menus is
50 pragma Preelaborate (Terminal_Interface.Curses.Menus);
51 include(`Menu_Linker_Options')dnl
52 include(`Linker_Options')
53 Space : Character renames Ada.Characters.Latin_1.Space;
58 ---------------------------
59 -- Interface constants --
60 ---------------------------
61 Null_Item : constant Item;
62 Null_Menu : constant Menu;
64 subtype Menu_Request_Code is Key_Code
65 range (Key_Max + 1) .. (Key_Max + 17);
67 -- The prefix M_ stands for "Menu Request"
68 M_Left_Item : constant Menu_Request_Code := Key_Max + 1;
69 M_Right_Item : constant Menu_Request_Code := Key_Max + 2;
70 M_Up_Item : constant Menu_Request_Code := Key_Max + 3;
71 M_Down_Item : constant Menu_Request_Code := Key_Max + 4;
72 M_ScrollUp_Line : constant Menu_Request_Code := Key_Max + 5;
73 M_ScrollDown_Line : constant Menu_Request_Code := Key_Max + 6;
74 M_ScrollDown_Page : constant Menu_Request_Code := Key_Max + 7;
75 M_ScrollUp_Page : constant Menu_Request_Code := Key_Max + 8;
76 M_First_Item : constant Menu_Request_Code := Key_Max + 9;
77 M_Last_Item : constant Menu_Request_Code := Key_Max + 10;
78 M_Next_Item : constant Menu_Request_Code := Key_Max + 11;
79 M_Previous_Item : constant Menu_Request_Code := Key_Max + 12;
80 M_Toggle_Item : constant Menu_Request_Code := Key_Max + 13;
81 M_Clear_Pattern : constant Menu_Request_Code := Key_Max + 14;
82 M_Back_Pattern : constant Menu_Request_Code := Key_Max + 15;
83 M_Next_Match : constant Menu_Request_Code := Key_Max + 16;
84 M_Previous_Match : constant Menu_Request_Code := Key_Max + 17;
86 -- For those who like the old 'C' names for the request codes
87 REQ_LEFT_ITEM : Menu_Request_Code renames M_Left_Item;
88 REQ_RIGHT_ITEM : Menu_Request_Code renames M_Right_Item;
89 REQ_UP_ITEM : Menu_Request_Code renames M_Up_Item;
90 REQ_DOWN_ITEM : Menu_Request_Code renames M_Down_Item;
91 REQ_SCR_ULINE : Menu_Request_Code renames M_ScrollUp_Line;
92 REQ_SCR_DLINE : Menu_Request_Code renames M_ScrollDown_Line;
93 REQ_SCR_DPAGE : Menu_Request_Code renames M_ScrollDown_Page;
94 REQ_SCR_UPAGE : Menu_Request_Code renames M_ScrollUp_Page;
95 REQ_FIRST_ITEM : Menu_Request_Code renames M_First_Item;
96 REQ_LAST_ITEM : Menu_Request_Code renames M_Last_Item;
97 REQ_NEXT_ITEM : Menu_Request_Code renames M_Next_Item;
98 REQ_PREV_ITEM : Menu_Request_Code renames M_Previous_Item;
99 REQ_TOGGLE_ITEM : Menu_Request_Code renames M_Toggle_Item;
100 REQ_CLEAR_PATTERN : Menu_Request_Code renames M_Clear_Pattern;
101 REQ_BACK_PATTERN : Menu_Request_Code renames M_Back_Pattern;
102 REQ_NEXT_MATCH : Menu_Request_Code renames M_Next_Match;
103 REQ_PREV_MATCH : Menu_Request_Code renames M_Previous_Match;
105 procedure Request_Name (Key : Menu_Request_Code;
108 function Request_Name (Key : Menu_Request_Code) return String;
115 Menu_Exception : exception;
119 pragma Warnings (Off);
120 include(`Menu_Opt_Rep')dnl
122 pragma Warnings (On);
124 function Default_Menu_Options return Menu_Option_Set;
125 -- Initial default options for a menu.
126 pragma Inline (Default_Menu_Options);
130 pragma Warnings (Off);
131 include(`Item_Rep')dnl
133 pragma Warnings (On);
135 function Default_Item_Options return Item_Option_Set;
136 -- Initial default options for an item.
137 pragma Inline (Default_Item_Options);
142 type Item_Array is array (Positive range <>) of aliased Item;
143 pragma Convention (C, Item_Array);
145 type Item_Array_Access is access Item_Array;
147 procedure Free (IA : in out Item_Array_Access;
148 Free_Items : Boolean := False);
149 -- Release the memory for an allocated item array
150 -- If Free_Items is True, call Delete() for all the items in
153 -- MANPAGE(`mitem_new.3x')
155 -- ANCHOR(`new_item()',`Create')
156 function Create (Name : String;
157 Description : String := "") return Item;
161 -- ANCHOR(`new_item()',`New_Item')
162 function New_Item (Name : String;
163 Description : String := "") return Item
167 -- ANCHOR(`free_item()',`Delete')
168 procedure Delete (Itm : in out Item);
170 -- Resets Itm to Null_Item
172 -- MANPAGE(`mitem_value.3x')
174 -- ANCHOR(`set_item_value()',`Set_Value')
175 procedure Set_Value (Itm : Item;
176 Value : Boolean := True);
178 pragma Inline (Set_Value);
180 -- ANCHOR(`item_value()',`Value')
181 function Value (Itm : Item) return Boolean;
183 pragma Inline (Value);
185 -- MANPAGE(`mitem_visible.3x')
187 -- ANCHOR(`item_visible()',`Visible')
188 function Visible (Itm : Item) return Boolean;
190 pragma Inline (Visible);
192 -- MANPAGE(`mitem_opts.3x')
194 -- ANCHOR(`set_item_opts()',`Set_Options')
195 procedure Set_Options (Itm : Item;
196 Options : Item_Option_Set);
198 -- An overloaded Set_Options is defined later. Pragma Inline appears there
200 -- ANCHOR(`item_opts_on()',`Switch_Options')
201 procedure Switch_Options (Itm : Item;
202 Options : Item_Option_Set;
203 On : Boolean := True);
205 -- ALIAS(`item_opts_off()')
206 -- An overloaded Switch_Options is defined later.
207 -- Pragma Inline appears there
209 -- ANCHOR(`item_opts()',`Get_Options')
210 procedure Get_Options (Itm : Item;
211 Options : out Item_Option_Set);
214 -- ANCHOR(`item_opts()',`Get_Options')
215 function Get_Options (Itm : Item := Null_Item) return Item_Option_Set;
217 -- An overloaded Get_Options is defined later. Pragma Inline appears there
219 -- MANPAGE(`mitem_name.3x')
221 -- ANCHOR(`item_name()',`Name')
222 procedure Name (Itm : Item;
225 function Name (Itm : Item) return String;
227 -- Implemented as function
228 pragma Inline (Name);
230 -- ANCHOR(`item_description();',`Description')
231 procedure Description (Itm : Item;
232 Description : out String);
235 function Description (Itm : Item) return String;
237 -- Implemented as function
238 pragma Inline (Description);
240 -- MANPAGE(`mitem_current.3x')
242 -- ANCHOR(`set_current_item()',`Set_Current')
243 procedure Set_Current (Men : Menu;
246 pragma Inline (Set_Current);
248 -- ANCHOR(`current_item()',`Current')
249 function Current (Men : Menu) return Item;
251 pragma Inline (Current);
253 -- ANCHOR(`set_top_row()',`Set_Top_Row')
254 procedure Set_Top_Row (Men : Menu;
255 Line : Line_Position);
257 pragma Inline (Set_Top_Row);
259 -- ANCHOR(`top_row()',`Top_Row')
260 function Top_Row (Men : Menu) return Line_Position;
262 pragma Inline (Top_Row);
264 -- ANCHOR(`item_index()',`Get_Index')
265 function Get_Index (Itm : Item) return Positive;
267 -- Please note that in this binding we start the numbering of items
268 -- with 1. So this is number is one more than you get from the low
270 pragma Inline (Get_Index);
272 -- MANPAGE(`menu_post.3x')
274 -- ANCHOR(`post_menu()',`Post')
275 procedure Post (Men : Menu;
276 Post : Boolean := True);
278 -- ALIAS(`unpost_menu()')
279 pragma Inline (Post);
281 -- MANPAGE(`menu_opts.3x')
283 -- ANCHOR(`set_menu_opts()',`Set_Options')
284 procedure Set_Options (Men : Menu;
285 Options : Menu_Option_Set);
287 pragma Inline (Set_Options);
289 -- ANCHOR(`menu_opts_on()',`Switch_Options')
290 procedure Switch_Options (Men : Menu;
291 Options : Menu_Option_Set;
292 On : Boolean := True);
294 -- ALIAS(`menu_opts_off()')
295 pragma Inline (Switch_Options);
297 -- ANCHOR(`menu_opts()',`Get_Options')
298 procedure Get_Options (Men : Menu;
299 Options : out Menu_Option_Set);
302 -- ANCHOR(`menu_opts()',`Get_Options')
303 function Get_Options (Men : Menu := Null_Menu) return Menu_Option_Set;
305 pragma Inline (Get_Options);
307 -- MANPAGE(`menu_win.3x')
309 -- ANCHOR(`set_menu_win()',`Set_Window')
310 procedure Set_Window (Men : Menu;
313 pragma Inline (Set_Window);
315 -- ANCHOR(`menu_win()',`Get_Window')
316 function Get_Window (Men : Menu) return Window;
318 pragma Inline (Get_Window);
320 -- ANCHOR(`set_menu_sub()',`Set_Sub_Window')
321 procedure Set_Sub_Window (Men : Menu;
324 pragma Inline (Set_Sub_Window);
326 -- ANCHOR(`menu_sub()',`Get_Sub_Window')
327 function Get_Sub_Window (Men : Menu) return Window;
329 pragma Inline (Get_Sub_Window);
331 -- ANCHOR(`scale_menu()',`Scale')
332 procedure Scale (Men : Menu;
333 Lines : out Line_Count;
334 Columns : out Column_Count);
336 pragma Inline (Scale);
338 -- MANPAGE(`menu_cursor.3x')
340 -- ANCHOR(`pos_menu_cursor()',`Position_Cursor')
341 procedure Position_Cursor (Men : Menu);
343 pragma Inline (Position_Cursor);
345 -- MANPAGE(`menu_mark.3x')
347 -- ANCHOR(`set_menu_mark()',`Set_Mark')
348 procedure Set_Mark (Men : Menu;
351 pragma Inline (Set_Mark);
353 -- ANCHOR(`menu_mark()',`Mark')
354 procedure Mark (Men : Menu;
358 function Mark (Men : Menu) return String;
360 -- Implemented as function
361 pragma Inline (Mark);
363 -- MANPAGE(`menu_attributes.3x')
365 -- ANCHOR(`set_menu_fore()',`Set_Foreground')
366 procedure Set_Foreground
368 Fore : Character_Attribute_Set := Normal_Video;
369 Color : Color_Pair := Color_Pair'First);
371 pragma Inline (Set_Foreground);
373 -- ANCHOR(`menu_fore()',`Foreground')
374 procedure Foreground (Men : Menu;
375 Fore : out Character_Attribute_Set);
378 -- ANCHOR(`menu_fore()',`Foreground')
379 procedure Foreground (Men : Menu;
380 Fore : out Character_Attribute_Set;
381 Color : out Color_Pair);
383 pragma Inline (Foreground);
385 -- ANCHOR(`set_menu_back()',`Set_Background')
386 procedure Set_Background
388 Back : Character_Attribute_Set := Normal_Video;
389 Color : Color_Pair := Color_Pair'First);
391 pragma Inline (Set_Background);
393 -- ANCHOR(`menu_back()',`Background')
394 procedure Background (Men : Menu;
395 Back : out Character_Attribute_Set);
397 -- ANCHOR(`menu_back()',`Background')
399 procedure Background (Men : Menu;
400 Back : out Character_Attribute_Set;
401 Color : out Color_Pair);
403 pragma Inline (Background);
405 -- ANCHOR(`set_menu_grey()',`Set_Grey')
408 Grey : Character_Attribute_Set := Normal_Video;
409 Color : Color_Pair := Color_Pair'First);
411 pragma Inline (Set_Grey);
413 -- ANCHOR(`menu_grey()',`Grey')
414 procedure Grey (Men : Menu;
415 Grey : out Character_Attribute_Set);
418 -- ANCHOR(`menu_grey()',`Grey')
421 Grey : out Character_Attribute_Set;
422 Color : out Color_Pair);
424 pragma Inline (Grey);
426 -- ANCHOR(`set_menu_pad()',`Set_Pad_Character')
427 procedure Set_Pad_Character (Men : Menu;
428 Pad : Character := Space);
430 pragma Inline (Set_Pad_Character);
432 -- ANCHOR(`menu_pad()',`Pad_Character')
433 procedure Pad_Character (Men : Menu;
434 Pad : out Character);
436 pragma Inline (Pad_Character);
438 -- MANPAGE(`menu_spacing.3x')
440 -- ANCHOR(`set_menu_spacing()',`Set_Spacing')
441 procedure Set_Spacing (Men : Menu;
442 Descr : Column_Position := 0;
443 Row : Line_Position := 0;
444 Col : Column_Position := 0);
446 pragma Inline (Set_Spacing);
448 -- ANCHOR(`menu_spacing()',`Spacing')
449 procedure Spacing (Men : Menu;
450 Descr : out Column_Position;
451 Row : out Line_Position;
452 Col : out Column_Position);
454 pragma Inline (Spacing);
456 -- MANPAGE(`menu_pattern.3x')
458 -- ANCHOR(`set_menu_pattern()',`Set_Pattern')
459 function Set_Pattern (Men : Menu;
460 Text : String) return Boolean;
462 -- Return TRUE if the pattern matches, FALSE otherwise
463 pragma Inline (Set_Pattern);
465 -- ANCHOR(`menu_pattern()',`Pattern')
466 procedure Pattern (Men : Menu;
469 pragma Inline (Pattern);
471 -- MANPAGE(`menu_format.3x')
473 -- ANCHOR(`set_menu_format()',`Set_Format')
474 procedure Set_Format (Men : Menu;
476 Columns : Column_Count);
477 -- Not implemented: 0 argument for Lines or Columns;
478 -- instead use Format to get the current sizes
479 -- The default format is 16 rows, 1 column. Calling
480 -- set_menu_format with a null menu pointer will change this
481 -- default. A zero row or column argument to set_menu_format
482 -- is interpreted as a request not to change the current
485 pragma Inline (Set_Format);
487 -- ANCHOR(`menu_format()',`Format')
488 procedure Format (Men : Menu;
489 Lines : out Line_Count;
490 Columns : out Column_Count);
492 pragma Inline (Format);
494 -- MANPAGE(`menu_hook.3x')
496 type Menu_Hook_Function is access procedure (Men : Menu);
497 pragma Convention (C, Menu_Hook_Function);
499 -- ANCHOR(`set_item_init()',`Set_Item_Init_Hook')
500 procedure Set_Item_Init_Hook (Men : Menu;
501 Proc : Menu_Hook_Function);
503 pragma Inline (Set_Item_Init_Hook);
505 -- ANCHOR(`set_item_term()',`Set_Item_Term_Hook')
506 procedure Set_Item_Term_Hook (Men : Menu;
507 Proc : Menu_Hook_Function);
509 pragma Inline (Set_Item_Term_Hook);
511 -- ANCHOR(`set_menu_init()',`Set_Menu_Init_Hook')
512 procedure Set_Menu_Init_Hook (Men : Menu;
513 Proc : Menu_Hook_Function);
515 pragma Inline (Set_Menu_Init_Hook);
517 -- ANCHOR(`set_menu_term()',`Set_Menu_Term_Hook')
518 procedure Set_Menu_Term_Hook (Men : Menu;
519 Proc : Menu_Hook_Function);
521 pragma Inline (Set_Menu_Term_Hook);
523 -- ANCHOR(`item_init()',`Get_Item_Init_Hook')
524 function Get_Item_Init_Hook (Men : Menu) return Menu_Hook_Function;
526 pragma Inline (Get_Item_Init_Hook);
528 -- ANCHOR(`item_term()',`Get_Item_Term_Hook')
529 function Get_Item_Term_Hook (Men : Menu) return Menu_Hook_Function;
531 pragma Inline (Get_Item_Term_Hook);
533 -- ANCHOR(`menu_init()',`Get_Menu_Init_Hook')
534 function Get_Menu_Init_Hook (Men : Menu) return Menu_Hook_Function;
536 pragma Inline (Get_Menu_Init_Hook);
538 -- ANCHOR(`menu_term()',`Get_Menu_Term_Hook')
539 function Get_Menu_Term_Hook (Men : Menu) return Menu_Hook_Function;
541 pragma Inline (Get_Menu_Term_Hook);
543 -- MANPAGE(`menu_items.3x')
545 -- ANCHOR(`set_menu_items()',`Redefine')
546 procedure Redefine (Men : Menu;
547 Items : Item_Array_Access);
549 pragma Inline (Redefine);
551 procedure Set_Items (Men : Menu;
552 Items : Item_Array_Access) renames Redefine;
553 -- pragma Inline (Set_Items);
555 -- ANCHOR(`menu_items()',`Items')
556 function Items (Men : Menu;
557 Index : Positive) return Item;
559 pragma Inline (Items);
561 -- ANCHOR(`item_count()',`Item_Count')
562 function Item_Count (Men : Menu) return Natural;
564 pragma Inline (Item_Count);
566 -- MANPAGE(`menu_new.3x')
568 -- ANCHOR(`new_menu()',`Create')
569 function Create (Items : Item_Array_Access) return Menu;
573 function New_Menu (Items : Item_Array_Access) return Menu renames Create;
575 -- ANCHOR(`free_menu()',`Delete')
576 procedure Delete (Men : in out Menu);
578 -- Reset Men to Null_Menu
581 -- MANPAGE(`menu_driver.3x')
583 type Driver_Result is (Menu_Ok,
588 -- ANCHOR(`menu_driver()',`Driver')
589 function Driver (Men : Menu;
590 Key : Key_Code) return Driver_Result;
592 -- Driver is not inlined
594 -- ANCHOR(`menu_requestname.3x')
595 -- Not Implemented: menu_request_name, menu_request_by_name
596 -------------------------------------------------------------------------------
598 type Item is new System.Storage_Elements.Integer_Address;
599 type Menu is new System.Storage_Elements.Integer_Address;
601 Null_Item : constant Item := 0;
602 Null_Menu : constant Menu := 0;
604 end Terminal_Interface.Curses.Menus;