1. ------------------------------------------------------------------------------ 
  2. --                  GtkAda - Ada95 binding for Gtk+/Gnome                   -- 
  3. --                                                                          -- 
  4. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  5. --                     Copyright (C) 1998-2014, AdaCore                     -- 
  6. --                                                                          -- 
  7. -- This library is free software;  you can redistribute it and/or modify it -- 
  8. -- under terms of the  GNU General Public License  as published by the Free -- 
  9. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  10. -- version. This library is distributed in the hope that it will be useful, -- 
  11. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  12. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  13. --                                                                          -- 
  14. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  15. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  16. -- version 3.1, as published by the Free Software Foundation.               -- 
  17. --                                                                          -- 
  18. -- You should have received a copy of the GNU General Public License and    -- 
  19. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  20. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  21. -- <http://www.gnu.org/licenses/>.                                          -- 
  22. --                                                                          -- 
  23. ------------------------------------------------------------------------------ 
  24.  
  25. --  <description> 
  26. -- 
  27. --  This package provides a ready to use high level dialog capability. 
  28. -- 
  29. --  </description> 
  30. --  <group>Windows</group> 
  31. --  <see>Gtk.Message_Dialog</see> 
  32.  
  33. with Glib; 
  34. with Gtk.Dialog; use Gtk.Dialog; 
  35. with Gtk.Enums;  use Gtk.Enums; 
  36. with Gtk.Window; use Gtk.Window; 
  37.  
  38. package Gtkada.Dialogs is 
  39.    pragma Elaborate_Body; 
  40.  
  41.    type Message_Dialog_Buttons is mod 2 ** 32; 
  42.    --  Define the set of values a button in a message dialog box can have. 
  43.  
  44.    type Button_Range is range 0 .. 8; 
  45.    --  The range of valid buttons. 
  46.  
  47.    Button_None   : constant Message_Dialog_Buttons := 0; 
  48.    Button_Yes    : constant Message_Dialog_Buttons := 2 ** 0; 
  49.    Button_No     : constant Message_Dialog_Buttons := 2 ** 1; 
  50.    Button_All    : constant Message_Dialog_Buttons := 2 ** 2; 
  51.    Button_OK     : constant Message_Dialog_Buttons := 2 ** 3; 
  52.    Button_Cancel : constant Message_Dialog_Buttons := 2 ** 4; 
  53.    Button_Abort  : constant Message_Dialog_Buttons := 2 ** 5; 
  54.    Button_Retry  : constant Message_Dialog_Buttons := 2 ** 6; 
  55.    Button_Ignore : constant Message_Dialog_Buttons := 2 ** 7; 
  56.    Button_Help   : constant Message_Dialog_Buttons := 2 ** 8; 
  57.  
  58.    type Message_Dialog_Type is 
  59.      (Warning, 
  60.       --  Message box with a yellow exclamation point. 
  61.  
  62.       Error, 
  63.       --  Message box with a red stop sign. 
  64.  
  65.       Information, 
  66.       --  Message box with a blue "i". 
  67.  
  68.       Confirmation, 
  69.       --  Message box with a blue question mark. 
  70.  
  71.       Custom 
  72.       --  Message box with no pixmap. The caption of the box should be set by 
  73.       --  the user. 
  74.      ); 
  75.    --  Define the values describing the type of message box. 
  76.    --  Used by the Message_Dialog function. 
  77.  
  78.    function Message_Dialog 
  79.      (Msg            : Glib.UTF8_String; 
  80.       Dialog_Type    : Message_Dialog_Type := Information; 
  81.       Buttons        : Message_Dialog_Buttons := Button_OK or Button_Help; 
  82.       Default_Button : Message_Dialog_Buttons := Button_OK; 
  83.       Help_Msg       : Glib.UTF8_String := ""; 
  84.       Title          : Glib.UTF8_String := ""; 
  85.       Justification  : Gtk_Justification := Justify_Center; 
  86.       Parent         : Gtk.Window.Gtk_Window := null) 
  87.       return Message_Dialog_Buttons; 
  88.    --  Display a message dialog box centered on the mouse. 
  89.    --  This will create a dialog box containing the specified message. 
  90.    --  Dialog_Type indicates the purpose of the dialog. 
  91.    --  Buttons indicates which buttons should appear in the dialog. 
  92.    --  Help_Msg is the message displayed in a separate dialog box when the help 
  93.    --  button is pressed while the dialog is displayed. 
  94.    --  If Help_Msg is null, a dialog containing the message 
  95.    --  "No help available" will be displayed. In both cases, the dialog 
  96.    --  displayed will only have a OK button. 
  97.    --  If Title is null, a default title will be chosen depending on the value 
  98.    --  of Dialog_Type. 
  99.    --  The dialog will be centered with regards to Parent 
  100.    -- 
  101.    --  This function will return only after the user pressed one of the buttons 
  102.    --  or deleted the dialog, by running an additional level of main loop. 
  103.    --  One of the following values will be returned: 
  104.    --    - Button_None 
  105.    --    - Button_Abort 
  106.    --    - Button_Yes 
  107.    --    - Button_Ok 
  108.    --    - Button_Retry 
  109.    --    - Button_No 
  110.    --    - Button_Cancel 
  111.    --    - Button_Ignore 
  112.    --    - Button_All 
  113.  
  114.    function Create_Gtk_Dialog 
  115.      (Msg           : Glib.UTF8_String; 
  116.       Dialog_Type   : Message_Dialog_Type := Information; 
  117.       Title         : Glib.UTF8_String := ""; 
  118.       Justification : Gtk_Justification := Justify_Center; 
  119.       Parent        : Gtk.Window.Gtk_Window := null) 
  120.       return Gtk.Dialog.Gtk_Dialog; 
  121.    --  Convenience function to create a new dialog. 
  122.    --  This function was introduced in GtkAda 2.0 to provide a compatibility 
  123.    --  with Message_Dialog, while using the standard Gtk.Dialog. You should add 
  124.    --  the buttons yourself, through Gtk.Dialog.Gtk_Dialog, and then display 
  125.    --  the dialog on the screen through Gtk.Dialog.Run. 
  126.    --  As opposed to Message_Dialog, you can provide your own custom buttons if 
  127.    --  needed. 
  128.  
  129. end Gtkada.Dialogs;