3.7) The menu bar.

The menu bar is composed of menus. The menus are composed of items.

3.7.1) The items.

type item_state =
    Selected
  | Unselected
  | Unselectable
;;
type gr_item =
  { it_window : gr_window
  ; mutable it_state : item_state
  ; mutable it_name : string
  ; mutable it_callback : gr_item -> event -> bool
  }
;;
The objects defined by gr_item are the lines of a menu. They are not managed directly by the main loop but by a special function linked to the menus. They define the contents and the action linked to a line of a menu. The variables are: The linked functions are:
gr_draw_item : gr_item -> coord -> int -> unit
gr_draw_item Item draws the item Item.
gr_item_managed : 'a -> 'b -> bool
is the function used by Camlwin to manage the items.

3.7.2) The menus.

type menu_state =
    Visible
  | Unvisible
;;
type gr_menu =
  { mn_window : gr_window
  ; mutable mn_left : int
  ; mutable mn_top : int
  ; mutable mn_state : menu_state
  ; mutable mn_nu_item : int
  ; mutable mn_name : string
  ; mutable mn_items : gr_item vect
  ; mutable mn_hide_area : image
  }
;;
gr_menu defines menus. Like the items, the menus are not elements of a window but the elements of another object: the menu bar (gr_toolbar). A menu is defined by: The linked functions are:
gr_draw_menu : gr_menu -> unit
gr_draw_menu Menu draws the menu Menu.
gr_erase_menu : gr_menu -> unit
gr_erase_menu Menu erases the menu Menu present on the screen.
gr_menu_managed : gr_menu -> event -> bool
this function is used by Camlwin to manage the menus.

3.7.3) The menu bar.

type gr_toolbar =
  { tb_window : gr_window
  ; mutable tb_items : gr_menu vect
  }
;;
A window must not have more than one menu bar. A menu bar is defined by the type gr_toolbar. It is a bar at the top of the window, with the menu name inside. When the user presses the mouse button on one name, the selected menu is opened. A menu bar is composed of: The functions linked with the menus bar are:
gr_draw_toolbar : gr_toolbar -> unit
gr_draw_toolbar Toolb draws the menus bar Toolb.
gr_toolbar_managed : gr_toolbar -> event -> bool
is the function used by Camlwin to manage the menu bar.