1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2013, AdaCore                   -- 
  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. --  A status bar is a special widget in which you can display messages. This 
  32. --  type of widget is generally found at the bottom of application windows, and 
  33. --  is used to display help or error messages. 
  34. -- 
  35. --  This widget works as a stack of messages, ie all older messages are kept 
  36. --  when a new one is inserted. It is of course possible to remove the most 
  37. --  recent message from the stack. This stack behavior is especially useful 
  38. --  when messages can be displayed from several places in your application. 
  39. --  Thus, each one subprogram that needs to print a message can simply push it 
  40. --  on the stack, and does not need to make sure that the user has had enough 
  41. --  time to read the previous message (a timeout can be set to automatically 
  42. --  remove the message after a specific delay) 
  43. -- 
  44. --  Each message is associated with a specific Context_Id. Each of this 
  45. --  context can have a special name, and these context can be used to organize 
  46. --  the messages into categories (for instance one for help messages and one 
  47. --  for error messages). You can then selectively remove the most recent 
  48. --  message of each category. 
  49. -- 
  50. --  </description> 
  51. --  <screenshot>gtk-status_bar</screenshot> 
  52. --  <group>Display widgets</group> 
  53. --  <testgtk>create_status.adb</testgtk> 
  54.  
  55. pragma Warnings (Off, "*is already use-visible*"); 
  56. with Glib;                 use Glib; 
  57. with Glib.GSlist;          use Glib.GSlist; 
  58. with Glib.Properties;      use Glib.Properties; 
  59. with Glib.Types;           use Glib.Types; 
  60. with Gtk.Box;              use Gtk.Box; 
  61. with Gtk.Buildable;        use Gtk.Buildable; 
  62. with Gtk.Enums;            use Gtk.Enums; 
  63. with Gtk.Orientable;       use Gtk.Orientable; 
  64. with Gtk.Widget;           use Gtk.Widget; 
  65. with Interfaces.C.Strings; use Interfaces.C.Strings; 
  66.  
  67. package Gtk.Status_Bar is 
  68.  
  69.    type Gtk_Status_Bar_Record is new Gtk_Hbox_Record with null record; 
  70.    type Gtk_Status_Bar is access all Gtk_Status_Bar_Record'Class; 
  71.  
  72.    type Context_Id is new Guint; 
  73.    type Message_Id is new Guint; 
  74.  
  75.    type Status_Bar_Msg is record 
  76.       Text    : Interfaces.C.Strings.chars_ptr; 
  77.       Context : Context_Id; 
  78.       Message : Message_Id; 
  79.    end record; 
  80.    --  A message from the queue. Each of this message is associated with a 
  81.    --  specific context, and has a specific number. 
  82.  
  83.    --  <no_doc> 
  84.    function Convert (Msg : Status_Bar_Msg) return System.Address; 
  85.    function Convert (Msg : System.Address) return Status_Bar_Msg; 
  86.    package Messages_List is new Glib.GSlist.Generic_SList (Status_Bar_Msg); 
  87.    --  </no_doc> 
  88.  
  89.    ------------------ 
  90.    -- Constructors -- 
  91.    ------------------ 
  92.  
  93.    procedure Gtk_New (Statusbar : out Gtk_Status_Bar); 
  94.    procedure Initialize (Statusbar : access Gtk_Status_Bar_Record'Class); 
  95.    --  Creates a new Gtk.Status_Bar.Gtk_Status_Bar ready for messages. 
  96.  
  97.    function Get_Type return Glib.GType; 
  98.    pragma Import (C, Get_Type, "gtk_statusbar_get_type"); 
  99.  
  100.    ------------- 
  101.    -- Methods -- 
  102.    ------------- 
  103.  
  104.    function Get_Context_Id 
  105.       (Statusbar           : access Gtk_Status_Bar_Record; 
  106.        Context_Description : UTF8_String) return Context_Id; 
  107.    --  Returns a new context identifier, given a description of the actual 
  108.    --  context. Note that the description is <emphasis>not</emphasis> shown in 
  109.    --  the UI. 
  110.    --  "context_description": textual description of what context the new 
  111.    --  message is being used in 
  112.  
  113.    function Get_Has_Resize_Grip 
  114.       (Statusbar : access Gtk_Status_Bar_Record) return Boolean; 
  115.    procedure Set_Has_Resize_Grip 
  116.       (Statusbar : access Gtk_Status_Bar_Record; 
  117.        Setting   : Boolean); 
  118.    --  Sets whether the statusbar has a resize grip. True by default. 
  119.    --  "setting": True to have a resize grip 
  120.  
  121.    function Get_Message_Area 
  122.       (Statusbar : access Gtk_Status_Bar_Record) 
  123.        return Gtk.Widget.Gtk_Widget; 
  124.    --  Retrieves the box containing the label widget. 
  125.    --  Since: gtk+ 2.20 
  126.  
  127.    procedure Pop 
  128.       (Statusbar : access Gtk_Status_Bar_Record; 
  129.        Context   : Context_Id); 
  130.    --  Removes the first message in the GtkStatusBar's stack with the given 
  131.    --  context id. Note that this may not change the displayed message, if the 
  132.    --  message at the top of the stack has a different context id. 
  133.    --  "context": a context identifier 
  134.  
  135.    function Push 
  136.       (Statusbar : access Gtk_Status_Bar_Record; 
  137.        Context   : Context_Id; 
  138.        Text      : UTF8_String) return Message_Id; 
  139.    --  Pushes a new message onto a statusbar's stack. Gtk.Status_Bar.Remove. 
  140.    --  "context": the message's context id, as returned by 
  141.    --  Gtk.Status_Bar.Get_Context_Id 
  142.    --  "text": the message to add to the statusbar 
  143.  
  144.    procedure Remove 
  145.       (Statusbar : access Gtk_Status_Bar_Record; 
  146.        Context   : Context_Id; 
  147.        Message   : Message_Id); 
  148.    --  Forces the removal of a message from a statusbar's stack. The exact 
  149.    --  Context_Id and Message_Id must be specified. 
  150.    --  "context": a context identifier 
  151.    --  "Message": a message identifier, as returned by Gtk.Status_Bar.Push 
  152.  
  153.    procedure Remove_All 
  154.       (Statusbar : access Gtk_Status_Bar_Record; 
  155.        Context   : Context_Id); 
  156.    --  Forces the removal of all messages from a statusbar's stack with the 
  157.    --  exact Context_Id. 
  158.    --  Since: gtk+ 2.22 
  159.    --  "context": a context identifier 
  160.  
  161.    ------------ 
  162.    -- Fields -- 
  163.    ------------ 
  164.  
  165.    function Get_Messages 
  166.       (Statusbar : access Gtk_Status_Bar_Record) 
  167.        return Gtk.Status_Bar.Messages_List.GSlist; 
  168.  
  169.    --------------------- 
  170.    -- Interfaces_Impl -- 
  171.    --------------------- 
  172.  
  173.    function Get_Orientation 
  174.       (Self : access Gtk_Status_Bar_Record) return Gtk.Enums.Gtk_Orientation; 
  175.    procedure Set_Orientation 
  176.       (Self        : access Gtk_Status_Bar_Record; 
  177.        Orientation : Gtk.Enums.Gtk_Orientation); 
  178.  
  179.    ---------------- 
  180.    -- Interfaces -- 
  181.    ---------------- 
  182.    --  This class implements several interfaces. See Glib.Types 
  183.    -- 
  184.    --  - "Buildable" 
  185.    -- 
  186.    --  - "Orientable" 
  187.  
  188.    package Implements_Buildable is new Glib.Types.Implements 
  189.      (Gtk.Buildable.Gtk_Buildable, Gtk_Status_Bar_Record, Gtk_Status_Bar); 
  190.    function "+" 
  191.      (Widget : access Gtk_Status_Bar_Record'Class) 
  192.    return Gtk.Buildable.Gtk_Buildable 
  193.    renames Implements_Buildable.To_Interface; 
  194.    function "-" 
  195.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  196.    return Gtk_Status_Bar 
  197.    renames Implements_Buildable.To_Object; 
  198.  
  199.    package Implements_Orientable is new Glib.Types.Implements 
  200.      (Gtk.Orientable.Gtk_Orientable, Gtk_Status_Bar_Record, Gtk_Status_Bar); 
  201.    function "+" 
  202.      (Widget : access Gtk_Status_Bar_Record'Class) 
  203.    return Gtk.Orientable.Gtk_Orientable 
  204.    renames Implements_Orientable.To_Interface; 
  205.    function "-" 
  206.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  207.    return Gtk_Status_Bar 
  208.    renames Implements_Orientable.To_Object; 
  209.  
  210.    ---------------- 
  211.    -- Properties -- 
  212.    ---------------- 
  213.    --  The following properties are defined for this widget. See 
  214.    --  Glib.Properties for more information on properties) 
  215.    -- 
  216.    --  Name: Has_Resize_Grip_Property 
  217.    --  Type: Boolean 
  218.    --  Flags: read-write 
  219.    --  Whether the statusbar has a grip for resizing the toplevel window. 
  220.  
  221.    Has_Resize_Grip_Property : constant Glib.Properties.Property_Boolean; 
  222.  
  223.    ------------- 
  224.    -- Signals -- 
  225.    ------------- 
  226.    --  The following new signals are defined for this widget: 
  227.    -- 
  228.    --  "text-popped" 
  229.    --     procedure Handler 
  230.    --       (Self    : access Gtk_Status_Bar_Record'Class; 
  231.    --        Context : Context_Id; 
  232.    --        Text    : UTF8_String); 
  233.    --    --  "context": the context id of the relevant message/statusbar. 
  234.    --    --  "text": the message that was just popped. 
  235.    --  Is emitted whenever a new message is popped off a statusbar's stack. 
  236.    -- 
  237.    --  "text-pushed" 
  238.    --     procedure Handler 
  239.    --       (Self    : access Gtk_Status_Bar_Record'Class; 
  240.    --        Context : Context_Id; 
  241.    --        Text    : UTF8_String); 
  242.    --    --  "context": the context id of the relevant message/statusbar. 
  243.    --    --  "text": the message that was pushed. 
  244.    --  Is emitted whenever a new message gets pushed onto a statusbar's stack. 
  245.  
  246.    Signal_Text_Popped : constant Glib.Signal_Name := "text-popped"; 
  247.    Signal_Text_Pushed : constant Glib.Signal_Name := "text-pushed"; 
  248.  
  249. private 
  250.    Has_Resize_Grip_Property : constant Glib.Properties.Property_Boolean := 
  251.      Glib.Properties.Build ("has-resize-grip"); 
  252. end Gtk.Status_Bar;