1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                 Copyright (C) 2001-2010, AdaCore                  -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- As a special exception, if other files instantiate generics from  -- 
  22. -- this unit, or you link this unit with other files to produce an   -- 
  23. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  24. -- executable to be covered by the GNU General Public License. This  -- 
  25. -- exception does not however invalidate any other reasons why the   -- 
  26. -- executable file  might be covered by the  GNU Public License.     -- 
  27. ----------------------------------------------------------------------- 
  28.  
  29. --  <description> 
  30. --  This widget organizes its children into resizable panes. Within each 
  31. --  pane, multiple children can be put, and they will be accessible through 
  32. --  a notebook. 
  33. --  </description> 
  34. --  <group>Layout containers</group> 
  35.  
  36. with Ada.Tags; 
  37. with GNAT.Strings; 
  38. with Glib;        use Glib; 
  39. with Glib.Main; 
  40. with Glib.Xml_Int; 
  41. with Gdk.Color; 
  42. with Gdk.Cursor; 
  43. with Gdk.Event; 
  44. with Gdk.Pixbuf; 
  45. with Gdk.Rectangle; 
  46. with Gtk.Accel_Group; 
  47. with Gtk.Box; 
  48. with Gtk.Drawing_Area; 
  49. with Gtk.Enums; 
  50. with Gtk.Event_Box; 
  51. with Gtk.Handlers; 
  52. with Gtk.Label; 
  53. with Gtk.Menu; 
  54. with Gtk.Menu_Item; 
  55. with Gtk.Notebook; 
  56. with Gtk.Style; 
  57. with Gtk.Check_Menu_Item; 
  58. with Gtk.Radio_Menu_Item; 
  59. with Gtk.Widget; 
  60. with Gtk.Window; 
  61. with Gtkada.Handlers; 
  62. with Gtkada.Multi_Paned; 
  63. with Pango.Font; 
  64. with Pango.Layout; 
  65.  
  66. package Gtkada.MDI is 
  67.  
  68.    type MDI_Window_Record is new Gtk.Widget.Gtk_Widget_Record with private; 
  69.    type MDI_Window is access all MDI_Window_Record'Class; 
  70.    --  Although this widget is implemented as a gtk_layout, you shouldn't 
  71.    --  use the standard Gtk_Layout functions like Put and Move yourself. 
  72.  
  73.    type MDI_Child_Record is new Gtk.Event_Box.Gtk_Event_Box_Record 
  74.      with private; 
  75.    type MDI_Child is access all MDI_Child_Record'Class; 
  76.    pragma No_Strict_Aliasing (MDI_Child); 
  77.    --  A child of the MDI, that encapsulates the widgets you have put in the 
  78.    --  MDI window. 
  79.    --  You can easily convert from this to the initial widget using the 
  80.    --  functions Find_MDI_Child and Get_Widget. 
  81.  
  82.    type MDI_Child_Array is array (Natural range <>) of MDI_Child; 
  83.    No_Children : constant MDI_Child_Array := (1 .. 0 => null); 
  84.  
  85.    type State_Type is (Normal, Floating, Invisible); 
  86.    --  This type indicates the state of an item in the MDI: 
  87.    --  - Normal: the item can be manipulated (moved and resized) by the user. 
  88.    --      It is found either in the middle notebook (maximized items), or 
  89.    --      in the layout. 
  90.    --  - Floating: the item has its own toplevel window, and is thus managed 
  91.    --      by the window manager. 
  92.    --  - Invisible: the child was part of a previously displayed perspective, 
  93.    --      but is no longer in the current perspective. We still keep it to 
  94.    --      reuse it when switching back to the previous perspective. 
  95.  
  96.    procedure Gtk_New 
  97.      (MDI   : out MDI_Window; 
  98.       Group : access Gtk.Accel_Group.Gtk_Accel_Group_Record'Class); 
  99.    --  Create a new MDI window. 
  100.    --  Note that it is recommended that you modify the style (Set_Background 
  101.    --  in State_Normal) to have a different color. 
  102.    --  You should call Setup_Toplevel_Window once you have added the MDI to a 
  103.    --  toplevel widget, so that focus is correctly handled when the toplevel 
  104.    --  window gains the focus 
  105.  
  106.    procedure Initialize 
  107.      (MDI   : access MDI_Window_Record'Class; 
  108.       Group : access Gtk.Accel_Group.Gtk_Accel_Group_Record'Class); 
  109.    --  Internal initialization function. 
  110.    --  See the section "Creating your own widgets" in the documentation. 
  111.  
  112.    procedure Setup_Toplevel_Window 
  113.      (MDI    : access MDI_Window_Record; 
  114.       Parent : access Gtk.Window.Gtk_Window_Record'Class); 
  115.    --  Setup Parent to properly handle focus when the window manager changes 
  116.    --  the window that currently has the focus. 
  117.    --  Parent must be the toplevel window that contains the MDI. 
  118.  
  119.    type Show_Tabs_Policy_Enum is (Always, Never, Automatic); 
  120.    type Title_Bars_Policy     is (Always, Never, Central_Only); 
  121.  
  122.    procedure Configure 
  123.      (MDI                       : access MDI_Window_Record; 
  124.       Opaque_Resize             : Boolean := False; 
  125.       Close_Floating_Is_Unfloat : Boolean := True; 
  126.       Title_Font         : Pango.Font.Pango_Font_Description := null; 
  127.       Background_Color   : Gdk.Color.Gdk_Color := Gdk.Color.Null_Color; 
  128.       Title_Bar_Color    : Gdk.Color.Gdk_Color := Gdk.Color.Null_Color; 
  129.       Focus_Title_Color  : Gdk.Color.Gdk_Color := Gdk.Color.Null_Color; 
  130.       Draw_Title_Bars    : Title_Bars_Policy   := Always; 
  131.       Tabs_Position      : Gtk.Enums.Gtk_Position_Type := Gtk.Enums.Pos_Bottom; 
  132.       Show_Tabs_Policy   : Show_Tabs_Policy_Enum := Automatic); 
  133.    --  Change the setup of the MDI. 
  134.    --  Close_Floating_Is_Unfloat, if True, means that closing a floating child 
  135.    --  will put it back in the MDI instead of destroying it (unless its flag 
  136.    --  Always_Destroy_Float is set). 
  137.    --  Title_Font is the font used in the title bars (if null, "sans 8" 
  138.    --  is used). 
  139.    --  The colors, when Null_Color, will not change the current setup. 
  140.    --  If Draw_Title_Bars is False, then no extra title bar will be displayed 
  141.    --  for the MDI children when they are maximized. This saves space on the 
  142.    --  screen. However, the notebook tabs will be highlighted with 
  143.    --  Title_Bar_Color in exchange. 
  144.    --  Tabs_Position indicates where the notebook tabs should be put. 
  145.    --  Show_Tabs_Policy indicates when the notebook tabs should be displayed. 
  146.  
  147.    ------------- 
  148.    -- Windows -- 
  149.    ------------- 
  150.  
  151.    type Child_Flags is mod 2 ** 5; 
  152.    Destroy_Button       : constant Child_Flags := 2 ** 2; 
  153.    Float_As_Transient   : constant Child_Flags := 2 ** 3; 
  154.    Always_Destroy_Float : constant Child_Flags := 2 ** 4; 
  155.    All_Buttons          : constant Child_Flags := Destroy_Button; 
  156.    --  Special flags to set up the widgets: 
  157.    --  The first is the buttons that should be displayed in the title 
  158.    --  bar of the MDI children. 
  159.    --  If Float_As_Transient is set, then the child will be set up as a 
  160.    --  transient window when floating: on most window managers, it will stay on 
  161.    --  top of the MDI, but the window will have less decorations in its title 
  162.    --  bar, in particular no destroy button. In such a case, <Esc> will close 
  163.    --  the window, or unfloat it depending on the MDI's setup, as is the case 
  164.    --  for all dialogs in GtkAda. The MDI's setup will be ignored (and the 
  165.    --  child always destroyed when Esc is pressed) if Always_Destroy_Float is 
  166.    --  true. 
  167.  
  168.    type Child_Group is new Positive; 
  169.    Group_Default : constant Child_Group := 1; 
  170.    Group_Any     : constant Child_Group := Child_Group'Last; 
  171.    --  This type can be used to help group windows by type within the MDI. 
  172.    --  Group_Default as a special status when computing the initial position 
  173.    --  for a window. But you can create your own groups as needed, so that for 
  174.    --  instance editors tend to be grouped with other editors, graphs with 
  175.    --  other graphs,... depending on your application. 
  176.    --  The group has an impact when a the last window from a notebook is 
  177.    --  closed: 
  178.    --  If the window belongs to Group_Default, and it is the last of its group, 
  179.    --  then the space currently occupied by that window is not reclaimed, and 
  180.    --  therefore an empty area will exist in the MDI. The idea is that for 
  181.    --  instance editors typically play a special role in an integrated 
  182.    --  development environment, and the users like to have them in the center 
  183.    --  of the window. When closing the last editor, they do not want the side 
  184.    --  windows (browsers, consoles,...) to take up that space that should 
  185.    --  really only be used for editors. 
  186.    --  To get such a behavior, editors should belong to Group_Default, and all 
  187.    --  other windows to custom groups. 
  188.    -- 
  189.    --  Do not use Group_Any, it is used internally with special meanings. 
  190.  
  191.    procedure Gtk_New 
  192.      (Child        : out MDI_Child; 
  193.       Widget       : access Gtk.Widget.Gtk_Widget_Record'Class; 
  194.       Flags        : Child_Flags := All_Buttons; 
  195.       Group        : Child_Group := Group_Default; 
  196.       Focus_Widget : Gtk.Widget.Gtk_Widget := null); 
  197.    --  Create a new MDI child that contains widget. 
  198.    --  Widget mustn't be of type Gtk_Window. 
  199.    -- 
  200.    --  You shouldn't access Widget directly afterwards, but should manipulate 
  201.    --  Child only. However, as a special exception, you can still pass Widget 
  202.    --  as a parameter to the subprograms in this package to manipulate it (e.g. 
  203.    --  in Raise_Child, ...) 
  204.    -- 
  205.    --  Note: You might have to call Set_Size_Request on Widget to set its 
  206.    --  initial size. This won't prevent it from being resized by the user. 
  207.    -- 
  208.    --  If Focus_Widget is not null, this is the widget that gets the keyboard 
  209.    --  focus when the child is selected. 
  210.  
  211.    procedure Initialize 
  212.      (Child        : access MDI_Child_Record'Class; 
  213.       Widget       : access Gtk.Widget.Gtk_Widget_Record'Class; 
  214.       Flags        : Child_Flags := All_Buttons; 
  215.       Group        : Child_Group := Group_Default; 
  216.       Focus_Widget : Gtk.Widget.Gtk_Widget := null); 
  217.    --  Internal initialization function. 
  218.    --  See the section "Creating your own widgets" in the documentation. 
  219.  
  220.    type Child_Position is 
  221.      (Position_Automatic, 
  222.       Position_Bottom, 
  223.       Position_Top, 
  224.       Position_Left, 
  225.       Position_Right); 
  226.    subtype Side_Position is Child_Position 
  227.       range Position_Bottom .. Position_Right; 
  228.    --  The initial position of windows within the MDI. 
  229.    --  In all cases, the initial location for a window is computed with the 
  230.    --  following algorithm. This algorithm is designed with the notion of 
  231.    --  groups of windows in mind, so that some windows (typically editors) have 
  232.    --  a special status. 
  233.    --     - If another window with the same Group is already in the MDI, the 
  234.    --       new window is put on top of it. 
  235.    --     - Otherwise, if Position_Automatic, if an empty area exists within 
  236.    --       the MDI, the new window is put in that area. 
  237.    --     - Else if the Position is Bottom .. Right, the new window is put 
  238.    --       below all others (resp. to the top, left or right) 
  239.    --     - Else the window is put on top of the currently selected window 
  240.  
  241.    procedure Put 
  242.      (MDI              : access MDI_Window_Record; 
  243.       Child            : access MDI_Child_Record'Class; 
  244.       Initial_Position : Child_Position := Position_Automatic); 
  245.    --  Add a new child to the MDI window, and return its embedding widget. 
  246.    --  Calling Put does not give the focus to the newly inserted widget. 
  247.    --  To do that, you should call Set_Focus_Child. 
  248.  
  249.    procedure Set_Size 
  250.      (MDI        : access MDI_Window_Record; 
  251.       Child      : access MDI_Child_Record'Class; 
  252.       Width      : Glib.Gint; 
  253.       Height     : Glib.Gint; 
  254.       Fixed_Size : Boolean := False); 
  255.    --  Forces a new size for a child. If Width or Height is left to -1, the 
  256.    --  matching size will be computed from the child's requisition. If they are 
  257.    --  left to 0, the corresponding length is left to its current value. 
  258.    --  If Fixed_Size is True, then the widget will not be resized when the MDI 
  259.    --  itself is resized (unless the user has first moved one of the handles to 
  260.    --  manually resize it). Otherwise, it will grow proportionally with the 
  261.    --  rest of the MDI. 
  262.  
  263.    procedure Close 
  264.      (MDI   : access MDI_Window_Record; 
  265.       Child : access Gtk.Widget.Gtk_Widget_Record'Class; 
  266.       Force : Boolean := False); 
  267.    --  Close the child that contains Child, and remove its window from the 
  268.    --  MDI. See also Close_Child if you need to close a MDI_Child itself. 
  269.    --  This first checks through a delete_event callback whether the child 
  270.    --  accepts to be closed. 
  271.    --  "delete_event" is not sent, and the child is automatically closed, if 
  272.    --  Force is set to True. 
  273.  
  274.    procedure Set_Title 
  275.      (Child       : access MDI_Child_Record; 
  276.       Title       : UTF8_String; 
  277.       Short_Title : UTF8_String := ""); 
  278.    --  Set the title for a child. Title is the title put in titlebar of 
  279.    --  the children, whereas Short_Title is the name of the notebook tab when 
  280.    --  children are maximized. By default, it is the same as Title. 
  281.    -- 
  282.    --  The default title is the empty string. 
  283.    --  This title will be the one used for the window when the child is set to 
  284.    --  floating state. 
  285.  
  286.    function Get_MDI (Child : access MDI_Child_Record) return MDI_Window; 
  287.    --  Return the MDI to which Child is associated. In Child is a floating 
  288.    --  child, it might not be in the MDI window itself. 
  289.  
  290.    function Get_Title (Child : access MDI_Child_Record) return UTF8_String; 
  291.    --  Return the title for a specific child 
  292.  
  293.    function Get_Short_Title 
  294.      (Child : access MDI_Child_Record) return UTF8_String; 
  295.    --  Return the name of the notebook tab used when children are maximized. 
  296.  
  297.    function Has_Title_Bar (Child : access MDI_Child_Record) return Boolean; 
  298.    --  Whether a title bar is currently displayed for Child 
  299.  
  300.    function Get_State (Child : access MDI_Child_Record) return State_Type; 
  301.    --  Return the current state of the child 
  302.  
  303.    procedure Set_Icon 
  304.      (Child : access MDI_Child_Record; 
  305.       Icon  : Gdk.Pixbuf.Gdk_Pixbuf); 
  306.    --  Associate an icon with Child. This icon is visible in the title bar, the 
  307.    --  notebook tabs, the Window menu and the interactive selection dialog. 
  308.    --  The icon is updated dynamically on the screen. 
  309.  
  310.    function Get_Icon 
  311.      (Child : access MDI_Child_Record) return Gdk.Pixbuf.Gdk_Pixbuf; 
  312.    --  Returns the icon associated with Child 
  313.  
  314.    --------------------------- 
  315.    -- Drag and Drop support -- 
  316.    --------------------------- 
  317.  
  318.    function Dnd_Data 
  319.      (Child : access MDI_Child_Record; Copy : Boolean) return MDI_Child; 
  320.    --  When a drag-and-drop operation took place to move a child from one 
  321.    --  position to the next, this function is called to know what child should 
  322.    --  be moved. 
  323.    --  As a result, the implementor can choose whether a copy of the child 
  324.    --  should be returned (creating a new view for an editor for instance), or 
  325.    --  if the child itself should be moved (the default). 
  326.    --  The returned MDI_Child must have been added to the MDI before it is 
  327.    --  returned. 
  328.    --  Copy is set to true if a copy operation was requested, to False if a 
  329.    --  simple move operation was requested. It can be ignored if Child doesn't 
  330.    --  know how to create a copy of itself for instance. 
  331.  
  332.    procedure Set_Dnd_Message 
  333.      (MDI     : access MDI_Window_Record; 
  334.       Message : String); 
  335.    --  Override the message that is displayed in the popup window while 
  336.    --  performing a drag. By default, this message mentions: 
  337.    --     "... will be (preserved|hidden) when changing perspective" 
  338.    --     "Use shift to create a new view for editors" 
  339.    --  so might not be suitable for all applications. 
  340.    --  Through this function you can override the message. If you insert the 
  341.    --  special sequence "(#)" in the message, it will be replaced either with 
  342.    --  "preserved" or "hidden" depending on where the drop occurs (the central 
  343.    --  area or the perspectives). 
  344.    --  You can use markup like "<b>...</b>" to put keywords in bold. 
  345.  
  346.    procedure Child_Drag_Begin 
  347.      (Child  : access MDI_Child_Record'Class; 
  348.       Event  : Gdk.Event.Gdk_Event); 
  349.    --  Starts a drag-and-drop operation for the child, so that it can be put in 
  350.    --  some other place on the desktop. This should only be called when a 
  351.    --  handler for the "button_press_event" signal, passing the event itself in 
  352.    --  parameter. 
  353.    --  The Child is immediately raised and gains the focus. 
  354.  
  355.    procedure Cancel_Child_Drag (Child : access MDI_Child_Record'Class); 
  356.    --  Cancel a drag operation started by Child_Drag_Begin. 
  357.    --  It doesn't call Child_Drag_Finished. 
  358.  
  359.    procedure Child_Drag_Finished (Child  : access MDI_Child_Record); 
  360.    --  Called when a drag operation is either aborted or completed. It should 
  361.    --  be overriden if special cleanup should be done. 
  362.  
  363.    ----------- 
  364.    -- Menus -- 
  365.    ----------- 
  366.  
  367.    type Tab_Contextual_Menu_Factory is access procedure 
  368.      (Child : access MDI_Child_Record'Class; 
  369.       Menu  : access Gtk.Menu.Gtk_Menu_Record'Class); 
  370.  
  371.    procedure Set_Tab_Contextual_Menu_Factory 
  372.      (MDI     : access MDI_Window_Record; 
  373.       Factory : Tab_Contextual_Menu_Factory); 
  374.    --  Set (or unset if Factory is null) the callback to create the contextual 
  375.    --  menu entries when the user clicks on a notebook tab. 
  376.    --  Factory should add entries to Menu (which already contains the default 
  377.    --  entries, but you can remove them if needed). 
  378.  
  379.    ------------------------ 
  380.    -- Selecting children -- 
  381.    ------------------------ 
  382.  
  383.    procedure Highlight_Child 
  384.      (Child : access MDI_Child_Record; Highlight : Boolean := True); 
  385.    --  Highlight the child until it is selected by the user. 
  386.    --  The color of its menu label and of the text in the notebook tabs is 
  387.    --  changed. 
  388.    --  Nothing is done if the child is already fully visible (either in the 
  389.    --  active page in one of the notebooks, or the child that has the selection 
  390.    --  in the layout). 
  391.    --  This is meant to be used as a graphical note to the user that the child 
  392.    --  has been updated and the user should look at it. 
  393.  
  394.    function Get_Focus_Child 
  395.      (MDI : access MDI_Window_Record) return MDI_Child; 
  396.    --  Return the child that currently has the MDI focus. 
  397.    --  null is returned if no child has the focus. 
  398.  
  399.    procedure Set_Focus_Child 
  400.      (MDI        : access MDI_Window_Record; 
  401.       Containing : access Gtk.Widget.Gtk_Widget_Record'Class); 
  402.    --  Give the focus to the child containing Containing. This will not 
  403.    --  Grab_Focus for the child in all cases, since you might want to give the 
  404.    --  focus to some specific part of your widget (an entry field,...) in some 
  405.    --  cases. 
  406.  
  407.    procedure Set_Focus_Child (Child : access MDI_Child_Record); 
  408.    --  Make Child the active widget, and raise it at the top. 
  409.  
  410.    procedure Check_Interactive_Selection_Dialog 
  411.      (MDI          : access MDI_Window_Record; 
  412.       Event        : Gdk.Event.Gdk_Event; 
  413.       Move_To_Next : Boolean; 
  414.       Only_Group   : Child_Group := Group_Any); 
  415.    --  Open the interactive dialog for selecting windows. 
  416.    --  This dialog should be open as a result of a key press event. 
  417.    --  Move_To_Next indicates whether we want to select the next child (True) 
  418.    --  or the previous child (False). 
  419.    --  This dialog will be closed only when the key that opened it is fully 
  420.    --  released. For instance, if the dialog was opened as a result of 
  421.    --  pressing Ctrl-Tab, the dialog will only be closed when Ctrl itself is 
  422.    --  released. 
  423.    --  You can call this procedure even if a dialog is currently open. This 
  424.    --  simply forces a move to the next or previous child. In fact, it is 
  425.    --  your responsability to call this procedure when the user presses 
  426.    --  the keys to move between children. 
  427.    -- 
  428.    --  If Event is null, then no dialog is displayed. Instead, the next or 
  429.    --  previous visible child is immediately selected. In such a mode, windows 
  430.    --  that are not on top of their respective notebook are ignored. This can 
  431.    --  be used to emulate Emacs's behavior for goto-other-window. 
  432.    -- 
  433.    --  If Only_Group is specified, then only the windows from that group will 
  434.    --  be shown in the dialog. 
  435.  
  436.    --  This function is not internal to the MDI since connecting to the 
  437.    --  key_press_event and key_release_event should be done in the gtk_window 
  438.    --  that contains the MDI. Otherwise, some events are intercepted by gtk+, 
  439.    --  for instance the key_release_events, and the key_press_events for some 
  440.    --  specified keys. 
  441.    --  It also gives the choice to the application of whether this feature is 
  442.    --  wanted or not. 
  443.  
  444.    ----------------------------------------- 
  445.    -- MDI_Child and encapsulated children -- 
  446.    ----------------------------------------- 
  447.  
  448.    function Get_Widget 
  449.      (Child : access MDI_Child_Record) return Gtk.Widget.Gtk_Widget; 
  450.    --  Return the widget that Child encapsulates. This is the widget you 
  451.    --  initially Put() in MDI. 
  452.  
  453.    function Find_MDI_Child 
  454.      (MDI    : access MDI_Window_Record; 
  455.       Widget : access Gtk.Widget.Gtk_Widget_Record'Class) return MDI_Child; 
  456.    --  Return the MDI_Child that encapsulates Widget. 
  457.    --  Widget must be the exact same one you gave in argument to Put. 
  458.    --  If the child is currently not visible in the perspective (for instance 
  459.    --  it was created for another perspective, but is not present in the 
  460.    --  current one), it is inserted automatically back in the MDI. 
  461.  
  462.    function Find_MDI_Child_From_Widget 
  463.      (Widget : access Gtk.Widget.Gtk_Widget_Record'Class) return MDI_Child; 
  464.    --  Return the MDI child that encapsulate the parent of Widget. 
  465.    --  As opposed to Find_MDI_Child, Widget can be anywhere within the 
  466.    --  widget tree. This function properly handles floating children 
  467.    --  If the child is currently not visible in the perspective (for instance 
  468.    --  it was created for another perspective, but is not present in the 
  469.    --  current one), it is inserted automatically back in the MDI. 
  470.  
  471.    function Find_MDI_Child_By_Tag 
  472.      (MDI : access MDI_Window_Record; 
  473.       Tag : Ada.Tags.Tag; 
  474.       Visible_Only : Boolean := False) return MDI_Child; 
  475.    --  Return the first child matching Tag 
  476.    --  If the child is currently not visible in the perspective (for instance 
  477.    --  it was created for another perspective, but is not present in the 
  478.    --  current one), it is inserted automatically back in the MDI. 
  479.    --  If Visible_Only is True, an invisible child is not returned. This is 
  480.    --  useful to check whether a child is currently visible. 
  481.  
  482.    function Find_MDI_Child_By_Name 
  483.      (MDI  : access MDI_Window_Record; 
  484.       Name : String) return MDI_Child; 
  485.    --  Return the first child matching Name. 
  486.    --  If the child is currently not visible in the perspective (for instance 
  487.    --  it was created for another perspective, but is not present in the 
  488.    --  current one), it is inserted automatically back in the MDI. 
  489.  
  490.    type Child_Iterator is private; 
  491.  
  492.    function First_Child 
  493.      (MDI               : access MDI_Window_Record; 
  494.       Group_By_Notebook : Boolean := False; 
  495.       Visible_Only      : Boolean := True) return Child_Iterator; 
  496.    --  Return an access to the first child of the MDI. 
  497.    -- 
  498.    --  If Group_By_Notebook is True, then the children are reported one after 
  499.    --  the other, but all the widget from the same notebook are reported in the 
  500.    --  same order as the notebook pages. Floating children do not belong to a 
  501.    --  notebook, and are also reported together. To find out to which notebook 
  502.    --  a child belongs, use Get_Notebook below. 
  503.    -- 
  504.    --  If Group_By_Notebook is False, it is garanteed that the first child is 
  505.    --  the one that currently has the focus in the MDI. The children are 
  506.    --  returned in the order in which they last had the focus. 
  507.    -- 
  508.    --  If Visible_Only is true, then only those children currently visible in 
  509.    --  the perspective are returned. The children that were part of a former 
  510.    --  perspective are not returned. 
  511.  
  512.    procedure Next (Iterator : in out Child_Iterator); 
  513.    --  Move to the next child in the MDI 
  514.  
  515.    function Get_Notebook 
  516.      (Iterator : Child_Iterator) return Gtk.Notebook.Gtk_Notebook; 
  517.    --  Return the notebook to which the current child belongs. null is returned 
  518.    --  for floating children 
  519.  
  520.    function Get (Iterator : Child_Iterator) return MDI_Child; 
  521.    --  Return the child pointed to by Iterator. 
  522.    --  If Iterator is no longer valid, null is returned. 
  523.  
  524.    ----------------------------------- 
  525.    -- Floating and closing children -- 
  526.    ----------------------------------- 
  527.  
  528.    procedure Float_Child 
  529.      (Child : access MDI_Child_Record'Class; Float : Boolean); 
  530.    --  Change the floating state of a child 
  531.  
  532.    function Is_Floating 
  533.      (Child : access MDI_Child_Record'Class) return Boolean; 
  534.    --  Return True if Child is currently in a separate window 
  535.  
  536.    procedure Close_Child 
  537.      (Child : access MDI_Child_Record'Class; 
  538.       Force : Boolean := False); 
  539.    --  Same as Close, but applies directly to a MDI_Child. 
  540.  
  541.    procedure Set_All_Floating_Mode 
  542.      (MDI : access MDI_Window_Record; All_Floating : Boolean); 
  543.    --  If All_Floating is set to true, the MDI will have a size of 0x0, and all 
  544.    --  children are set to floating. This can be used if you wish to let the 
  545.    --  window manager handle the windows. If All_Floating is True, children 
  546.    --  can no longer be maximized. 
  547.  
  548.    procedure Use_Short_Titles_For_Floats 
  549.      (MDI : access MDI_Window_Record; Short_Titles : Boolean); 
  550.    --  If Short_Titles is set to true, all floating children will use their 
  551.    --  short titles. 
  552.  
  553.    --------------------------- 
  554.    -- Reorganizing children -- 
  555.    --------------------------- 
  556.  
  557.    procedure Raise_Child 
  558.      (Child : access MDI_Child_Record'Class; Give_Focus : Boolean := True); 
  559.    --  Put Child in the foreground. 
  560.    --  Note that this does not give the focus to this child, unless 
  561.    --  Give_Focus is set to True. If Child and the current focus child are in 
  562.    --  the same notebook, Child will always gain the focus, so that the focus 
  563.    --  is not left on an invisible window. 
  564.  
  565.    function Is_Raised (Child : access MDI_Child_Record'Class) return Boolean; 
  566.    --  Whether the child is currently raised, ie fully visible to the user 
  567.  
  568.    procedure Lower_Child (Child : access MDI_Child_Record'Class); 
  569.    --  Put Child in the background. 
  570.    --  If the children are maximized, this selected the next page from the 
  571.    --  notebook. 
  572.  
  573.    type Split_Mode is 
  574.      (Before, Before_Reuse, 
  575.       After,  After_Reuse, 
  576.       Any_Side_Reuse); 
  577.    --  How a child should be split: 
  578.    --  If "Before", the child is put above or to the left of its current 
  579.    --  position. A new window is created to containing it. If the "_Reuse" 
  580.    --  version is used, and a window already exist at that position, the child 
  581.    --  will be put in it instead of creating a new one. 
  582.    --  Any_Side_Reuse indicates that the child will be put on either side, 
  583.    --  depending on where a window already exists. If there is no window on the 
  584.    --  side, a new one is created. 
  585.  
  586.    procedure Split 
  587.      (MDI           : access MDI_Window_Record; 
  588.       Orientation   : Gtk.Enums.Gtk_Orientation; 
  589.       Child         : MDI_Child := null; 
  590.       Mode          : Split_Mode := Before; 
  591.       Width, Height : Glib.Gint := 0); 
  592.    --  Split the notebook containing Child (by default, the current focus 
  593.    --  child). 
  594.    --  Mode indicates in which direction the splitting should occur. If you 
  595.    --  are splitting a child in the central area, splitting will never reuse 
  596.    --  a window outside of the central area. 
  597.    --  Width and Height indicate the desired geometry for the splitted area, 
  598.    --  0 indicate a 50/50 split. 
  599.  
  600.    ---------------------- 
  601.    -- Desktop Handling -- 
  602.    ---------------------- 
  603.    --  The MDI provides a way to save desktops, i.e the list of children 
  604.    --  currently open in the MDI and their location. It can then restore the 
  605.    --  desktop at some later point. 
  606.    -- 
  607.    --  Desktops require support from the widgets that are put in the MDI. They 
  608.    --  need to register a function to save them and a function to recreate 
  609.    --  them. Using Ada streams for this didn't prove workable since some 
  610.    --  children might need extra parameters not available to them through 
  611.    --  streams. This is why the following subprograms are in a generic package, 
  612.    --  so that you can pass whatever parameter(s) is needed in your 
  613.    --  application. 
  614.    -- 
  615.    --  Desktops are saved and restored in XML trees. 
  616.    -- 
  617.    --  If you need your application to load a "default desktop" when the user 
  618.    --  hasn't defined one, it is recommended that you distribute an actual 
  619.    --  file containing this desktop. You could also create the XML tree in 
  620.    --  memory yourself, and thus hard-code the default desktop if need be. 
  621.  
  622.    generic 
  623.       type User_Data is private; 
  624.       --  Generic type of parameter that is passed to all the children's save 
  625.       --  and restore functions. 
  626.  
  627.       --  This package needs to be instantiated at library level 
  628.  
  629.    package Desktop is 
  630.  
  631.       function Create_Menu 
  632.         (MDI               : access MDI_Window_Record'Class; 
  633.          Accel_Path_Prefix : String := "<gtkada>"; 
  634.          User              : User_Data) return Gtk.Menu.Gtk_Menu; 
  635.       --  Create a dynamic menu that can then be inserted into a menu bar. This 
  636.       --  menu is dynamic, ie its content will changed based on the focus 
  637.       --  child. 
  638.       --  If this function is called several times, the same menu is returned 
  639.       --  every time. Accel_Path_Prefix must be the same for every call. 
  640.       --  Accel_Path_Prefix is used so that the key shortcuts associated with 
  641.       --  these menu items can be changed dynamically by the user (see 
  642.       --  gtk-accel_map.ads). The prefix must start with "<" and end with ">". 
  643.       --  User is used for the callbacks on perspective changes, and passed to 
  644.       --  Load_Perspective 
  645.  
  646.       type Save_Desktop_Function is access function 
  647.         (Widget : access Gtk.Widget.Gtk_Widget_Record'Class; 
  648.          User   : User_Data) return Glib.Xml_Int.Node_Ptr; 
  649.       --  A general function that dumps the parameters of a widget into an XML 
  650.       --  tree. 
  651.       -- 
  652.       --  Note: you should register one such function for all the widget types 
  653.       --  you will put in the MDI and that need to be saved when a desktop is 
  654.       --  saved. The MDI will call all the registered functions one after the 
  655.       --  other. Therefore, your function should return null if Widget is not 
  656.       --  of a type that is it can handle. 
  657.  
  658.       type Load_Desktop_Function is access function 
  659.         (MDI : MDI_Window; Node : Glib.Xml_Int.Node_Ptr; User : User_Data) 
  660.          return MDI_Child; 
  661.       --  A general function that loads a widget from an XML tree. 
  662.       -- 
  663.       --  As for Save_Desktop_Function, this function should return null if it 
  664.       --  doesn't know how to handle Node or if Node doesn't describe a widget 
  665.       --  type that it can handle. 
  666.       -- 
  667.       --  This function returns an MDI_Widget that has been put in the MDI. 
  668.  
  669.       procedure Register_Desktop_Functions 
  670.         (Save : Save_Desktop_Function; 
  671.          Load : Load_Desktop_Function); 
  672.       --  Register a set of functions to save and load desktops for some 
  673.       --  specific widget types. 
  674.       --  Neither Save nor Load can be null. 
  675.  
  676.       function Restore_Desktop 
  677.         (MDI          : access MDI_Window_Record'Class; 
  678.          Perspectives : Glib.Xml_Int.Node_Ptr; 
  679.          From_Tree    : Glib.Xml_Int.Node_Ptr; 
  680.          User         : User_Data) return Boolean; 
  681.       --  Restore the contents of the MDI from its saved XML tree. 
  682.       --  Perspectives is the list of perspectives. It is cloned as needed, so 
  683.       --  the caller is still responsible for freeing it. The first perspective 
  684.       --  is loaded. 
  685.       --  From_Tree is the part of the desktop that describes the editor area. 
  686.       --  User is passed as a parameter to all of the Load_Desktop_Function 
  687.       --  registered by the widgets. 
  688.       --  Return False if the desktop couldn't be loaded 
  689.       --  It also restores the size and position of the toplevel window that 
  690.       --  contains the MDI 
  691.  
  692.       procedure Load_Perspective 
  693.         (MDI          : access MDI_Window_Record'Class; 
  694.          Name         : String; 
  695.          User         : User_Data); 
  696.       --  Replace the current perspective by another one. This preserves the 
  697.       --  editor area. 
  698.       --  If the perspective does not exist, nothing is done, unless no 
  699.       --  perspective is currently loaded (in which case we load the first 
  700.       --  on in the list). 
  701.  
  702.       procedure Create_Perspective 
  703.         (MDI          : access MDI_Window_Record'Class; 
  704.          Name         : String; 
  705.          User         : User_Data); 
  706.       --  Create a new perspective with the current desktop layout. If another 
  707.       --  perspective with the same name exists, it is replaced. 
  708.  
  709.       procedure Define_Perspective 
  710.         (MDI          : access MDI_Window_Record'Class; 
  711.          XML          : Glib.Xml_Int.Node_Ptr; 
  712.          User         : User_Data); 
  713.       --  Define a new perspective (in the same format as returned by 
  714.       --  Save_Desktop, the central area is under control of the user so you 
  715.       --  cannot change it). 
  716.       --  If such a perspective already exists, nothing is done (since the user 
  717.       --  might have modified it already). 
  718.       --  XML's root node is the <perspective> node, including its "name" 
  719.       --  attribute. 
  720.       --  XML must be freed by the caller. 
  721.  
  722.       procedure Save_Desktop 
  723.         (MDI          : access MDI_Window_Record'Class; 
  724.          User         : User_Data; 
  725.          Perspectives : out Glib.Xml_Int.Node_Ptr; 
  726.          Central      : out Glib.Xml_Int.Node_Ptr); 
  727.       --  Return XML representations of the perspectives and central area. Both 
  728.       --  nodes need to be freed by the caller, and can be saved in a file (to 
  729.       --  be passed to Restore_Desktop later on). 
  730.       --  This function calls each of the registered function for the children 
  731.       --  of the MDI. 
  732.       --  It also saves the size and position of the toplevel window that 
  733.       --  contains the MDI 
  734.  
  735.       function Get_XML_Content 
  736.         (MDI : access MDI_Window_Record'Class; 
  737.          Tag : String) return Glib.Xml_Int.Node_Ptr; 
  738.       --  Return the first XML subtree starting with 'Tag'. This allows a 
  739.       --  module to retrieve its content after the 'Load_Desktop' call. 
  740.  
  741.       procedure Free_Registered_Desktop_Functions; 
  742.       --  Free the memory allocated for the registered functions. 
  743.  
  744.    private 
  745.       type Register_Node_Record; 
  746.       type Register_Node is access Register_Node_Record; 
  747.       type Register_Node_Record is record 
  748.          Save : Save_Desktop_Function; 
  749.          Load : Load_Desktop_Function; 
  750.          Next : Register_Node; 
  751.       end record; 
  752.  
  753.       type Perspective_Menu_Item_Record 
  754.         is new Gtk.Radio_Menu_Item.Gtk_Radio_Menu_Item_Record 
  755.       with record 
  756.          MDI  : MDI_Window; 
  757.          Name : Natural; 
  758.          User : User_Data; 
  759.       end record; 
  760.       type Perspective_Menu_Item 
  761.         is access all Perspective_Menu_Item_Record'Class; 
  762.  
  763.       procedure Change_Perspective 
  764.         (Item : access Gtk.Widget.Gtk_Widget_Record'Class); 
  765.       CP_Access : constant 
  766.         Gtkada.Handlers.Widget_Callback.Marshallers.Marshaller := 
  767.         Gtkada.Handlers.Widget_Callback.To_Marshaller 
  768.           (Change_Perspective'Access); 
  769.       --  Internal, but needed so that we can have a 'Access on a callback 
  770.  
  771.       procedure Create_Perspective_CB 
  772.         (Item : access Gtk.Widget.Gtk_Widget_Record'Class); 
  773.       CreateP_Access : constant 
  774.         Gtkada.Handlers.Widget_Callback.Marshallers.Marshaller := 
  775.         Gtkada.Handlers.Widget_Callback.To_Marshaller 
  776.           (Create_Perspective_CB'Access); 
  777.  
  778.       Registers : Register_Node; 
  779.       --  Global variable that contains the list of functions that have been 
  780.       --  registered. 
  781.    end Desktop; 
  782.  
  783.    function Desktop_Was_Loaded (MDI : access MDI_Window_Record) return Boolean; 
  784.    --  Return True if a desktop was loaded, False if the MDI is only the result 
  785.    --  of calls to Gtk_New and Put. 
  786.  
  787.    function List_Of_Perspectives 
  788.      (MDI : access MDI_Window_Record) 
  789.       return GNAT.Strings.String_List_Access; 
  790.    --  Return the list of perspectives known to the MDI. The caller must not 
  791.    --  free the list 
  792.  
  793.    function Current_Perspective 
  794.      (MDI : access MDI_Window_Record'Class) return String; 
  795.    --  Return the name of the currently displayed perspective 
  796.  
  797.    ------------- 
  798.    -- Signals -- 
  799.    ------------- 
  800.  
  801.    --  <signals> 
  802.    --  The following new signals are defined for this widget: 
  803.    -- 
  804.    --  - "child_selected" 
  805.    --    procedure Handler 
  806.    --       (MDI : access MDI_Window_Record'Class; Child : System.Address); 
  807.    -- 
  808.    --    This signal is emitted when a new child has gained the focus. Convert 
  809.    --    Child to a MDI_Child by calling Gtk.Arguments.To_Object. This can be 
  810.    --    used to change some global information at the MDI level. You should 
  811.    --    connect to "selected" (see below) instead if you want to change some 
  812.    --    information at the child level. 
  813.    --    Child might be null if no child has the focus anymore 
  814.    -- 
  815.    --  - "float_child" 
  816.    --    procedure Handler 
  817.    --       (MDI : access MDI_Window_Record'Class; Child : System.Address); 
  818.    -- 
  819.    --    A child was set as floating in the MDI. A similar signal is emitted on 
  820.    --    the child itself. 
  821.    -- 
  822.    --  - "child_title_changed" 
  823.    --    procedure Handler 
  824.    --      (MDI : access MDI_Window_Record'Class; Child : System.Address); 
  825.    -- 
  826.    --    Emitted when the title of a child is changed. This signal is not 
  827.    --    emitted if Set_Title is called for a child that hasn't been put in the 
  828.    --    MDI yet. 
  829.    -- 
  830.    --  - "child_added" 
  831.    --     procedure Handler 
  832.    --       (MDI : access MDI_Window_Record'Class; Child : System.Address); 
  833.    --     Emitted when a new child is added. You cannot use the "add" signal 
  834.    --     since in fact the children are added to notebooks that are part of 
  835.    --     the MDI, and thus "add" is only emitted when a new notebook is 
  836.    --     created. 
  837.    -- 
  838.    --  - "child_removed" 
  839.    --     procedure Handler 
  840.    --       (MDI : access MDI_Window_Record'Class; Child : System.Address); 
  841.    --     Emitted when a new child is removed. You cannot use the "remove" 
  842.    --     signal since in fact the children are removed from notebooks that are 
  843.    --     part of the MDI, and thus "remove" is only emitted when a new 
  844.    --     notebook is destroyed. 
  845.    --     When this signal is emitted, Child no longer contains a widget, and 
  846.    --     is no longer part of the children, although you can still access its 
  847.    --     titles. 
  848.    -- 
  849.    --  - "child_icon_changed" 
  850.    --     procedure Handler 
  851.    --       (MDI : access MDI_Window_Record'Class; Child : System.Address); 
  852.    --     Emitted when the icon for Child has changed 
  853.    -- 
  854.    --  - "children_reorganized" 
  855.    --     procedure Handler (MDI : access MDI_Window_Record'Class); 
  856.    --     Emitted when the children have been reorganized: either a split 
  857.    --     occurred, or a window was dropped into another position 
  858.    -- 
  859.    --  - "perspective_changed" 
  860.    --     procedure Handler (MDI : access MDI_Window_Record'Class); 
  861.    --     Called when the user has selected a new perspective. One use is to 
  862.    --     save the new desktop to a file. 
  863.    -- 
  864.    --  </signals> 
  865.    -- 
  866.    --  <signals> 
  867.    --  The following new signals are defined for the MDI_Child_Record object: 
  868.    -- 
  869.    --  - "delete_event" 
  870.    --    function Handler (Child : access Gtk_Widget_Record'Class) 
  871.    --                     return Boolean; 
  872.    -- 
  873.    --    This signal is emitted for each item in the MDI window before it is 
  874.    --    actually deleted. The child is destroyed only if the handler returns 
  875.    --    False. 
  876.    --    Note that the Child passed in argument is exactly the one you passed 
  877.    --    to Put to insert it in the MDI window. 
  878.    --    Note that this is also the signal to use to prevent top level 
  879.    --    Gtk_Window from being destroyed. 
  880.    -- 
  881.    --  - "selected" 
  882.    --    procedure Handler (Child : access MDI_Child_Record'Class); 
  883.    -- 
  884.    --    This is emitted when the child is selected, ie gains the 
  885.    --    MDI focus. You should probably also connect to the "grab_focus" signal 
  886.    --    to be informed when the child gets the keyboard focus. This can be 
  887.    --    used to transfer the focus to some specific part of the 
  888.    --    widget. Connecting to "grab_focus" should be done with the After 
  889.    --    parameter set to True. 
  890.    -- 
  891.    --  - "float_child" 
  892.    --    procedure Handler (Child : access MDI_Child_Record'Class); 
  893.    -- 
  894.    --    Emitted when a child is set as floating 
  895.    -- 
  896.    --  - "unfloat_child" 
  897.    --    procedure Handler (Child : access MDI_Child_Record'Class); 
  898.    -- 
  899.    --    Emitted when a child is put back in the main MDI window 
  900.    -- 
  901.    --  - "child_state_changed" 
  902.    --    procedure Handler (Child : access MDI_Child_Record'Class); 
  903.    -- 
  904.    --    Emitted when the state of the child has changed. See the function 
  905.    --    Get_State. In particular, this signal can be detected when a child is 
  906.    --    removed from the current perspective (the new state is "invisible"), 
  907.    --    and when it is put back (the new state is "normal" or "floating"). 
  908.    -- 
  909.    --  </signals> 
  910.  
  911.    Signal_Child_Selected       : constant Signal_Name := "child_selected"; 
  912.    Signal_Float_Child          : constant Signal_Name := "float_child"; 
  913.    Signal_Child_Title_Changed  : constant Signal_Name := "child_title_changed"; 
  914.    Signal_Child_Added          : constant Signal_Name := "child_added"; 
  915.    Signal_Child_Removed        : constant Signal_Name := "child_removed"; 
  916.    Signal_Child_Icon_Changed   : constant Signal_Name := "child_icon_changed"; 
  917.    Signal_Delete_Event         : constant Signal_Name := "delete_event"; 
  918.    Signal_Selected             : constant Signal_Name := "selected"; 
  919.    Signal_Unfloat_Child        : constant Signal_Name := "unfloat_child"; 
  920.    Signal_Perspective_Changed  : constant Signal_Name := "perspective_changed"; 
  921.    Signal_Children_Reorganized : constant Signal_Name := 
  922.                                    "children_reorganized"; 
  923.    Signal_Child_State_Changed  : constant Signal_Name := "child_state_changed"; 
  924.  
  925. private 
  926.    type String_Access is access all UTF8_String; 
  927.  
  928.    type MDI_Child_Record is new Gtk.Event_Box.Gtk_Event_Box_Record with record 
  929.       Initial : Gtk.Widget.Gtk_Widget; 
  930.       --  The widget we use to build this child. 
  931.  
  932.       Main_Box : Gtk.Box.Gtk_Box; 
  933.       --  The main container. 
  934.  
  935.       State : State_Type := Normal; 
  936.  
  937.       Group : Child_Group := Group_Default; 
  938.  
  939.       Title       : String_Access; 
  940.       Short_Title : String_Access; 
  941.       --  Title of the item, as it appears in the title bar. 
  942.       --  These are UTF8-Encoded 
  943.  
  944.       XML_Node_Name : String_Access; 
  945.       --  The name of the XML node when this child is saved in a desktop (if 
  946.       --  we know it). This is used to reuse a child when switching 
  947.       --  perspectives. 
  948.  
  949.       MDI : MDI_Window; 
  950.       --  The MDI to which the child belongs. We cannot get this information 
  951.       --  directly from Get_Parent since some children are actually floating 
  952.       --  and do not belong to the MDI anymore. 
  953.  
  954.       Menu_Item : Gtk.Radio_Menu_Item.Gtk_Radio_Menu_Item; 
  955.       --  The item in the dynamic menu that represents this child. 
  956.  
  957.       Flags : Child_Flags; 
  958.  
  959.       Focus_Widget : Gtk.Widget.Gtk_Widget; 
  960.       --  The widget which should actually get the keyboard focus 
  961.  
  962.       Icon : Gdk.Pixbuf.Gdk_Pixbuf; 
  963.  
  964.       Title_Box : Gtk.Box.Gtk_Box; 
  965.       --  Box that contains the title. It will be resized whenever the title 
  966.       --  font changes. 
  967.  
  968.       Title_Area : Gtk.Drawing_Area.Gtk_Drawing_Area; 
  969.       --  Area used to draw the title and icon. 
  970.  
  971.       Tab_Label : Gtk.Label.Gtk_Label; 
  972.       --  label used when child is in a notebook, null if not in a notebook 
  973.    end record; 
  974.  
  975.    type Child_Iterator (Group_By_Notebook : Boolean := False) is record 
  976.       Visible_Only : Boolean; 
  977.  
  978.       case Group_By_Notebook is 
  979.          when False => 
  980.             Iter : Gtk.Widget.Widget_List.Glist; 
  981.  
  982.          when True => 
  983.             MDI                 : MDI_Window; 
  984.  
  985.             --  While iterating children 
  986.             Paned_Iter          : Gtkada.Multi_Paned.Child_Iterator; 
  987.  
  988.             --  Whether we have already visited the children of the central 
  989.             --  area. This is True while iterating them, False afterward 
  990.             In_Central          : Boolean; 
  991.  
  992.             --  While iterating the pages of a specific notebook (notebook is 
  993.             --  set to null when returning floating children) 
  994.             Notebook            : Gtk.Notebook.Gtk_Notebook; 
  995.             Notebook_Page       : Glib.Gint; 
  996.  
  997.             --  While iterating the floating children 
  998.             Floating_Iter       : Gtk.Widget.Widget_List.Glist; 
  999.       end case; 
  1000.    end record; 
  1001.  
  1002.    type Drag_Status is (No_Drag, In_Pre_Drag, In_Drag); 
  1003.  
  1004.    type MDI_Window_Record is new Gtkada.Multi_Paned.Gtkada_Multi_Paned_Record 
  1005.    with record 
  1006.       Items : Gtk.Widget.Widget_List.Glist := Gtk.Widget.Widget_List.Null_List; 
  1007.       --  The list of all MDI children. This includes children in the editor 
  1008.       --  area, even though they are technically in a separate multi_paned. 
  1009.       --  Warning: this list might contain items which are in fact invisible in 
  1010.       --  the MDI (in fact that are not even children of the MDI), if they 
  1011.       --  existed in a previous perspective but no longer in the current one. 
  1012.  
  1013.       Desktop_Was_Loaded : Boolean := False; 
  1014.       --  True if a desktop was loaded 
  1015.  
  1016.       Loading_Desktop : Boolean := False; 
  1017.       --  Whether we are currently loading the desktop. This impacts a number 
  1018.       --  of focus and sizing parameters, so that the desktop can be restored 
  1019.       --  as accurately as possible. 
  1020.  
  1021.       Delay_Before_Focus_Id : Glib.Main.G_Source_Id := Glib.Main.No_Source_Id; 
  1022.       Delay_Before_Focus : Glib.Guint := 700; 
  1023.       --  Delay in ms before a floating window gains the GPS focus, after the 
  1024.       --  "focus_in" event. In all floating mode, this ensures that when the 
  1025.       --  user is passing briefly over floating windows they do not gain the 
  1026.       --  focus, thus potentially leaving the focus to the window that had it 
  1027.       --  at the beginning of the move. 
  1028.       --  Set to 0 to remove any delay. 
  1029.  
  1030.       Focus_Child : MDI_Child := null; 
  1031.       --  The child that currently has the focus. Some default actions will 
  1032.       --  apply to this child only. 
  1033.  
  1034.       Dnd_Message : String_Access; 
  1035.       --  The message displayed during a dnd operation (see Set_Dnd_Message) 
  1036.  
  1037.       Accel_Path_Prefix  : String_Access; 
  1038.       --  The Accel path used for the dynamic menu 
  1039.  
  1040.       Menu               : Gtk.Menu.Gtk_Menu; 
  1041.       Float_Menu_Item    : Gtk.Check_Menu_Item.Gtk_Check_Menu_Item; 
  1042.       Float_Menu_Item_Id : Gtk.Handlers.Handler_Id; 
  1043.       Close_Menu_Item    : Gtk.Menu_Item.Gtk_Menu_Item; 
  1044.       --  The dynamic menu used to provide access to the most common 
  1045.       --  functions of MDI. 
  1046.  
  1047.       Tab_Factory : Tab_Contextual_Menu_Factory; 
  1048.       --  Build the contextual menu when right-clicking on tabs 
  1049.  
  1050.       Title_Layout        : Pango.Layout.Pango_Layout; 
  1051.       --  Layout used to draw titles in the MDI children 
  1052.  
  1053.       Title_Bar_Height    : Glib.Gint; 
  1054.       --  Height of the title bar for all the children 
  1055.  
  1056.       Close_Floating_Is_Unfloat : Boolean; 
  1057.       --  True if destroying a floating window will put the child back in the 
  1058.       --  MDI instead of destroying it. False if the child should be destroyed 
  1059.       --  (provided it accepts so in its delete_event handler). 
  1060.  
  1061.       Highlight_Style : Gtk.Style.Gtk_Style; 
  1062.       --  Style to use to highlight the tabs and menus for the highlighted 
  1063.       --  children. 
  1064.  
  1065.       Background_Color  : Gdk.Color.Gdk_Color := Gdk.Color.Null_Color; 
  1066.       Title_Bar_Color   : Gdk.Color.Gdk_Color := Gdk.Color.Null_Color; 
  1067.       Focus_Title_Color : Gdk.Color.Gdk_Color := Gdk.Color.Null_Color; 
  1068.       Default_Title_Color : Gdk.Color.Gdk_Color := Gdk.Color.Null_Color; 
  1069.  
  1070.       Cursor_Cross      : Gdk.Cursor.Gdk_Cursor; 
  1071.       Cursor_Fleur      : Gdk.Cursor.Gdk_Cursor; 
  1072.       --  Cached cursors 
  1073.  
  1074.       Draw_Title_Bars   : Title_Bars_Policy := Always; 
  1075.       Tabs_Position     : Gtk.Enums.Gtk_Position_Type := Gtk.Enums.Pos_Bottom; 
  1076.       Show_Tabs_Policy  : Show_Tabs_Policy_Enum := Automatic; 
  1077.  
  1078.       Selection_Dialog : Gtk.Widget.Gtk_Widget; 
  1079.       --  The interactive dialog for selecting new children. 
  1080.  
  1081.       Dnd_Window       : Gtk.Window.Gtk_Window; 
  1082.       Dnd_Window_Label : Gtk.Label.Gtk_Label; 
  1083.       --  The small window displayed while a drag-and-drop operation is 
  1084.       --  taking place. 
  1085.  
  1086.       Group : Gtk.Accel_Group.Gtk_Accel_Group; 
  1087.  
  1088.       All_Floating_Mode : Boolean := False; 
  1089.       --  Set to true if all windows should be set to floating 
  1090.  
  1091.       Use_Short_Titles_For_Floats : Boolean := False; 
  1092.       --  Set to true if all floating children should use their short titles 
  1093.  
  1094.       --  Handling of Dnd 
  1095.       Drag_Start_X, Drag_Start_Y : Gint; 
  1096.       In_Drag           : Drag_Status := No_Drag; 
  1097.       Dnd_Rectangle     : Gdk.Rectangle.Gdk_Rectangle;  --  Highlighted area 
  1098.       Dnd_Target        : Gdk.Gdk_Window;     --  The current target for DND 
  1099.       Dnd_Target_Window : Gtk.Window.Gtk_Window;  --  The overlay window 
  1100.  
  1101.       --  Loaded perspectives 
  1102.       Perspective_Menu_Item  : Gtk.Menu_Item.Gtk_Menu_Item; 
  1103.       Perspectives           : Glib.Xml_Int.Node_Ptr; 
  1104.       View_Contents          : Glib.Xml_Int.Node_Ptr; 
  1105.       Perspective_Names      : GNAT.Strings.String_List_Access; 
  1106.       Central                : Gtkada.Multi_Paned.Gtkada_Multi_Paned; 
  1107.  
  1108.       Current_Perspective    : Glib.Xml_Int.Node_Ptr; 
  1109.       --  pointer into Perspectives 
  1110.    end record; 
  1111.  
  1112.    pragma Inline (Get_Widget); 
  1113.    pragma Inline (Get_Focus_Child); 
  1114.    pragma Inline (Get); 
  1115.    pragma Inline (Next); 
  1116.    pragma Inline (First_Child); 
  1117.  
  1118. end Gtkada.MDI;