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