TABLE OF CONTENTS
- 1. Widgets/Menu
- 1.1. Menu/Menu.Tk_Menu
- 1.2. Menu/Menu.Activate
- 1.3. Menu/Menu.AddMenu
- 1.4. Menu/Menu.Clone
- 1.5. Menu/Menu.Create_(function)
- 1.6. Menu/Menu.Create_(procedure)
- 1.7. Menu/Menu.Delete
- 1.8. Menu/Menu.Entry_Cget
- 1.9. Menu/Menu.Entry_Configure_(function)
- 1.10. Menu/Menu.Entry_Configure_(procedure)
- 1.11. Menu/Menu.Get_Widget
- 1.12. Menu/Menu.Index
- 1.13. Menu/Menu.Insert
- 1.14. Menu/Menu.Invoke
- 1.15. Menu/Menu.Menu_Type
- 1.16. Menu/Menu.Post_(function)
- 1.17. Menu/Menu.Post_(procedure)
- 1.18. Menu/Menu.PostCascade
- 1.19. Menu/Menu.Tk_Popup
- 1.20. Menu/Menu.Unpost
- 1.21. Menu/Menu.XPosition
- 1.22. Menu/Menu.YPosition
Widgets/Menu [ Packages ]
[ Top ] [ Widgets ] [ Packages ]
FUNCTION
Provides code for manipulate Tk widget Menu
SOURCE
package Tcl.Tk.Ada.Widgets.Menu with SPARK_Mode is pragma Elaborate_Body;
Menu/Menu.Tk_Menu [ Types ]
FUNCTION
This is a non-abstract type derived directly from Tk_Widget. Each of the derived widgets redefines the Create subprogram in order to create the correct type of widget.
SOURCE
type Tk_Menu is new Tk_Widget with private;
Menu/Menu.Activate [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Activate the selected item in the selected menu. Previously active is deactivated.
SOURCE
procedure Activate(MenuWidget: in Tk_Menu'Class; Index: in String) with Pre => Index /= "";
PARAMETERS
MenuWidget - Tk_Menu in which item will be activated Index - Index of the item to activate
EXAMPLE
-- Activate the second element in menu My_Menu Activate(My_Menu, "1");
COMMANDS
MenuWidget activate index
HISTORY
8.6.4 - Added
Menu/Menu.AddMenu [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Add element to the menu.
SOURCE
procedure Add (MenuWidget: in Tk_Menu'Class; EntryType: in String; Options: in String := "") with Pre => EntryType /= "";
PARAMETERS
MenuWidget - Tk_Menu widget to which the element will be added EntryType - Tk type of entry to add Options - Tk options for menu entry to add. Default value is empty
EXAMPLE
-- Add an element with text Quit which will be quit from the program to the My_Menu menu Add(My_Menu, "command", "-label Quit -command exit");
SEE ALSO
Insert
COMMANDS
MenuWidget add EntryType ?options?
HISTORY
8.6.1 - Added
Menu/Menu.Clone [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Make a clone of the selected menu
SOURCE
procedure Clone (MenuWidget: in Tk_Menu'Class; NewPathName, CloneType: in String) with Pre => NewPathName /= "" and CloneType in "normal" | "menubar" | "tearoff" | "";
PARAMETERS
MenuWidget - Tk_Menu which will be cloned NewPathName - Name of a newly created clone menu CloneType - Type of newly created clone menu
EXAMPLE
-- Clone My_Menu to new normal menu which will have pathname .mynewmenu Clone(My_Menu, ".mynewmenu", "normal");
COMMANDS
MenuWidget clone newPathname cloneType
HISTORY
8.6.4 - Added
Menu/Menu.Create_(function) [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Creates a new Tk_Menu in the specified interpreter.
SOURCE
overriding function Create (pathName: in String; options: in String := ""; Interp: in Tcl_Interp := Null_Interp) return Tk_Menu with Global => null;
PARAMETERS
pathName - Tk path (starts with dot) for the widget options - Options which will be passed to the widget. Default value is empty Interp - Tcl interpreter to which the widget will be created. If null, the widget will be created in the "contextual" interpreter. Default value is null.
RESULT
Newly created Tk_Menu
EXAMPLE
-- Create a new menu with pathname .mymenu My_Menu: constant Tk_Menu := Create(".mymenu");
SEE ALSO
Menu.Create_(procedure)
COMMANDS
menu pathName ?options?
HISTORY
8.6.1 - Added
Menu/Menu.Create_(procedure) [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Creates a new Tk_Menu in the specified interpreter.
SOURCE
overriding procedure Create (Widgt: out Tk_Menu; pathName: in String; options: in String := ""; Interp: in Tcl_Interp := Null_Interp) with Global => null;
PARAMETERS
Widgt - Tk_Menu which will be created pathName - Tk path (starts with dot) for the widget options - Options which will be passed to the widget. Default value is empty Interp - Tcl interpreter to which the widget will be created. If null, the widget will be created in the "contextual" interpreter. Default value is null.
OUTPUT
Newly created Tk_Menu as parameter Widgt
EXAMPLE
-- Create a new menu My_Menu with pathname .mymenu and with disabled tearoff option on the current Tcl interpreter declare My_Menu: Tk_Menu; begin Create(My_Menu, ".mymenu", "-tearoff false"); end;
SEE ALSO
Menu.Create_(function)
COMMANDS
menu pathName ?options?
HISTORY
8.6.1 - Added
Menu/Menu.Delete [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Delete elements from the menu.
SOURCE
procedure Delete (MenuWidget: in Tk_Menu; StartIndex: in String; EndIndex: in String := "") with Pre'Class => StartIndex /= "";
PARAMETERS
MenuWidget - Tk_Menu widget from which elementrs will be deleted StartIndex - Index of first element which will be deleted EndIndex - Index of last element which will be deleted. If empty, it will be that same like StartIndex. Default is empty.
EXAMPLE
-- Delete second menu entry from the My_Menu menu Delete(My_Menu, "1");
COMMANDS
MenuWidget delete startindex ?endindex?
HISTORY
8.6.1 - Added
Menu/Menu.Entry_Cget [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Get current value of the selected option of the selected entry in the selected Tk_Menu
SOURCE
function Entry_Cget (MenuWidget: in Tk_Menu; Index, Option: in String) return String with Pre'Class => Index /= "" and Option /= "";
PARAMETERS
MenuWidget - Tk_Menu widget in which option will be queried Index - Index of the menu entry for which option will be queried Option - Name of the option to query
RESULT
Current value of the selected Option in the selected menu entry
EXAMPLE
-- Get the font used by first entry in My_Menu menu Font: constant String := Entry_Cget(My_Menu, "0", "-font");
SEE ALSO
Menu.Entry_Configure_(function)
COMMANDS
MenuWidget entrycget index option
HISTORY
8.6.4 - Added
Menu/Menu.Entry_Configure_(function) [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Get configuration of the selected menu entry
SOURCE
function Entry_Configure (MenuWidget: in Tk_Menu; Index: in String) return String with Pre'Class => Index /= "";
PARAMETERS
MenuWidget - Tk_Menu widget from which entry configuration will be taken Index - Index of the menu entry to get configuration
RESULT
String with list of options and their values for the selected menu entry
EXAMPLE
-- Get the configuration options of the active menu entry in My_Menu menu Options: constant String := Entry_Configure(My_Menu, "active");
SEE ALSO
Menu.Entry_Configure_(procedure), Menu.Entry_Cget
COMMANDS
MenuWidget entryconfigure index
HISTORY
8.6.2 - Added
Menu/Menu.Entry_Configure_(procedure) [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Configure selected menu entry
SOURCE
procedure Entry_Configure (MenuWidget: in Tk_Menu; Index, Options: in String) with Pre'Class => Index /= "" and Options /= "";
PARAMETERS
MenuWidget - Tk_Menu widget from which entry will be configured Index - Index of the menu entry to configure Options - Tk options for the menu entry
EXAMPLE
-- Set the label of the third entry in My_Menu menu to hello world Entry_Configure(My_Menu, "2", "-label {hello world}");
SEE ALSO
Menu.Entry_Configure_(function)
COMMANDS
MenuWidget entryconfigure index options
HISTORY
8.6.2 - Added
Menu/Menu.Get_Widget [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Get the existing Tk_Menu widget
SOURCE
overriding function Get_Widget (pathName: in String; Interp: in Tcl_Interp := Get_Context) return Tk_Menu with Global => null;
PARAMETERS
pathName - Tk path (starts with dot) for the widget Interp - Tcl interpreter on which the widget exists. Can be empty. Default value is current Tcl interpreter
RESULT
Existing Tk_Menu widget
EXAMPLE
-- Get menu widget with name .mymenu on the current Tcl interpreter My_Menu: constant Tk_Menu := Get_Widget(".mymenu");
HISTORY
8.6.9 - Added
Menu/Menu.Index [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Get the numerical index of the selected menu entry in the selected menu
SOURCE
function Index(MenuWidget: in Tk_Menu; Index: in String) return String with Pre'Class => Index /= "";
PARAMETERS
MenuWidget - Tk_Menu widget in which entry will be queried Index - Index of the entry to query
RESULT
Numerical index of the selected menu entry or none if Index was set to none
EXAMPLE
-- Get the index of the last element in the My_Menu menu EntryIndex: constant String := Index(My_Menu, "end");
COMMANDS
MenuWidget index index
HISTORY
8.6.4 - Added
Menu/Menu.Insert [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Add the selected menu entry before other selected entry.
SOURCE
procedure Insert (MenuWidget: in Tk_Menu'Class; Index, EntryType: in String; Options: in String := "") with Pre => Index /= "" and EntryType /= "";
PARAMETERS
MenuWidget - Tk_Menu widget to which the element will be added Index - Index of the other menu entry before which this entry will be added EntryType - Tk type of entry to add Options - Tk options for menu entry to add. Default value is empty
EXAMPLE
-- Add an element with text Quit which will be quit from the program to the My_Menu menu as second entry Add(My_Menu, "2" ,"command", "-label Quit -command exit");
SEE ALSO
Menu.AddMenu
COMMANDS
MenuWidget insert index EntryType ?options?
HISTORY
8.6.4 - Added
Menu/Menu.Invoke [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Invoke command associated with the selected menu entry in the selected menu
SOURCE
function Invoke(MenuWidget: in Tk_Menu; Index: in String) return String with Pre'Class => Index /= "";
PARAMETERS
MenuWidget - Tk_Menu widget from which entry will be activated Index - Index of the menu entry to activate
RESULT
Value returned by the invoked command
EXAMPLE
-- Invoke the third element of the My_Menu menu Result: constant String := Invoke(My_Menu, "2");
COMMANDS
MenuWidget invoke index
HISTORY
8.6.3 - Added
Menu/Menu.Menu_Type [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Get type of the selected entry in the selected Tk_Menu
SOURCE
function Menu_Type (MenuWidget: in Tk_Menu; Index: in String) return String with Pre'Class => Index /= "";
PARAMETERS
MenuWidget - Tk_Menu in which the selected entry will be queried Index - Index of the menu entry which will be queried
RESULT
Type of the selected entry - command, separator or tearoff
EXAMPLE
-- Get the type of the active entry in My_Menu menu MType: constant String := Menu_Type(My_Menu, "active");
COMMANDS
MenuWidget type index
HISTORY
8.6.4 - Added
Menu/Menu.Post_(function) [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Display the selected menu at the selected coordinates
SOURCE
function Post(MenuWidget: in Tk_Menu; X, Y: in String) return String with Pre'Class => X /= "" and Y /= "";
PARAMETERS
MenuWidget - Tk_Menu widget which will be shown X - X coordinate in the root window where Tk_Menu will be shown Y - Y coordinate in the root window where Tk_Menu will be shown
RESULT
If Postcommand was set for the selecte MenuWidget, return result of this command. If error occured during posting the menu, return error. Otherwise return {}
EXAMPLE
-- Post My_Menu menu at point (34, 67) and get the result of the command Result: constant String := Post(My_Menu, "34", "67");
SEE ALSO
Menu.Post_(procedure)
COMMANDS
MenuWidget post x y
HISTORY
8.6.4 - Added
Menu/Menu.Post_(procedure) [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Display the selected menu at the selected coordinates
SOURCE
procedure Post(MenuWidget: in Tk_Menu; X, Y: in String) with Pre'Class => X /= "" and Y /= "";
PARAMETERS
MenuWidget - Tk_Menu widget which will be shown X - X coordinate in the root window where Tk_Menu will be shown Y - Y coordinate in the root window where Tk_Menu will be shown
EXAMPLE
-- Post My_Menu menu at point (10, 87) Post(My_Menu, "10", "87");
SEE ALSO
Menu.Post_(function)
COMMANDS
MenuWidget post x y
HISTORY
8.6.4 - Added
Menu/Menu.PostCascade [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Show submenu associated with the cascade entry with the selected index. Unpost previously posted submenu
SOURCE
procedure PostCascade(MenuWidget: in Tk_Menu; Index: in String) with Pre'Class => Index /= "";
PARAMETERS
MenuWidget - Tk_Menu from which submenu will be taken Index - Index of cascade menu entry to show
EXAMPLE
-- Show the submenu of My_Menu from the second entry PostCascade(My_Menu, "1");
COMMANDS
MenuWidget postcascade index
HISTORY
8.6.4 - Added
Menu/Menu.Tk_Popup [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Post the selected menu at the selected screen position
SOURCE
procedure Tk_Popup (MenuWidget: in Tk_Menu; X, Y: in String; MenuEntry: in String := "") with Pre'Class => X /= "" and Y /= "";
PARAMETERS
MenuWidget - Tk_Menu which will be posted X - X screen coordinate on which MenuWidget will be posted Y - Y screen coordinate on which MenuWidget will be posted MenuEntry - Index of menu entry on which menu will be positioned. If empty, top left corner of the menu will be set at the selected position.
EXAMPLE
-- Show My_Menu menu at point (24, 89) on the screen Tk_Popup(My_Menu, "24", "89");
COMMANDS
tk_popup MenuWidget x y ?MenuEntry?
HISTORY
8.6.6 - Added
Menu/Menu.Unpost [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Unmap the selected menu so it is no longer displayed. This procedure don't work on Windows and MacOS as those platforms have their own way of unposting menus.
SOURCE
procedure Unpost(MenuWidget: in Tk_Menu);
PARAMETERS
MenuWidget - Tk_Menu which will be unposted
EXAMPLE
-- Hide My_Menu menu Unpost(My_Menu);
COMMANDS
MenuWidget unpost
HISTORY
8.6.4 - Added
Menu/Menu.XPosition [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Get X coordinate of the leftmost pixel of the selected menu entry in the selected Tk_Menu
SOURCE
function XPosition (MenuWidget: in Tk_Menu; Index: in String) return String with Pre'Class => Index /= "";
PARAMETERS
MenuWidget - Tk_Menu in which the selected entry will be queried Index - Index of the selected entry to query
RESULT
X coordinate of the leftmost pixel of the selected menu entry in MenuWidget
EXAMPLE
-- Get the X coordinate of the first element in My_Menu menu X_Position: constant String := XPosition(My_Menu, "0");
SEE ALSO
Menu.YPosition
COMMANDS
MenuWidget xposition index
HISTORY
8.6.4 - Added
Menu/Menu.YPosition [ Subprograms ]
[ Top ] [ Menu ] [ Subprograms ]
FUNCTION
Get Y coordinate of the topmost pixel of the selected menu entry in the selected Tk_Menu
SOURCE
function YPosition (MenuWidget: in Tk_Menu; Index: in String) return String with Pre'Class => Index /= "";
PARAMETERS
MenuWidget - Tk_Menu in which the selected entry will be queried Index - Index of the selected entry to query
RESULT
Y coordinate of the topmost pixel of the selected menu entry in MenuWidget
EXAMPLE
-- Get the Y coordinate of the first element in My_Menu menu Y_Position: constant String := YPosition(My_Menu, "0");
SEE ALSO
Menu.XPosition
COMMANDS
MenuWidget yposition index
HISTORY
8.6.4 - Added