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