Toc Gallery Index Tree Gtk.GEntry

Screenshot

No screeshot

Hierarchy

Description

A Gtk_Entry is a single line text editing widget. The text is automatically scrolled if it is longer than can be displayed on the screen, so that the cursor position is visible at all times.

See Gtk_Text_View for a multiple-line text editing widget.

Types

  • type Gtk_Entry is access all Gtk_Entry_Record'Class;
  • type Gtk_Entry_Record is new Gtk.Editable.Gtk_Editable_Record with private;
    Gtk_Entry is actually a child of Gtk_Widget, and implements the Gtk_Editable interface, but GtkAda does not support yet interfaces, so use direct inheritance for now ???
  • type Gtk_GEntry is Gtk_Entry;

Subprograms

  • procedure Gtk_New (Widget : out Gtk_Entry);
    Create a new entry with no maximum length for the text
  • procedure Initialize (Widget : access Gtk_Entry_Record'Class);
    Internal initialization function. See the section "Creating your own widgets" in the documentation.
  • function Get_Type return Gtk.Gtk_Type;
    Return the internal value associated with a Gtk_Entry.
  • procedure Set_Visibility (The_Entry : access Gtk_Entry_Record; Visible : Boolean);
    function Get_Visibility (The_Entry : access Gtk_Entry_Record) return Boolean;
    Set the visibility of the characters in the entry. If Visible is set to False, the characters will be replaced with the invisible character ('*' by default) in the display, and when the text is copied elsewhere.
  • procedure Set_Invisible_Char (The_Entry : access Gtk_Entry_Record; Char : Gunichar);
    function Get_Invisible_Char (The_Entry : access Gtk_Entry_Record) return Gunichar;
    Set the character to use in place of the actual text when Set_Visibility has been called to set text visibility to False. i.e. this is the character used in "password mode" to show the user how many characters have been typed. The default invisible char is an asterisk ('*'). If you set the invisible char to 0, then the user will get no feedback at all; there will be no text on the screen as they type. for entries with visisbility set to false. See Set_Invisible_Char.
  • procedure Set_Has_Frame (The_Entry : access Gtk_Entry_Record; Setting : Boolean := True);
    function Get_Has_Frame (The_Entry : access Gtk_Entry_Record) return Boolean;
    Set whether the entry has a beveled frame around it.
  • procedure Set_Max_Length (The_Entry : access Gtk_Entry_Record; Max : Gint);
    function Get_Max_Length (The_Entry : access Gtk_Entry_Record) return Gint;
    Set the maximum length for the text. The current text is truncated if needed.
  • procedure Set_Activates_Default (The_Entry : access Gtk_Entry_Record; Setting : Boolean);
    function Get_Activates_Default (The_Entry : access Gtk_Entry_Record) return Boolean;
    If Setting is True, pressing Enter in the Entry will activate the default widget for the window containing the entry. This usually means that the dialog box containing the entry will be closed, since the default widget is usually one of the dialog buttons.

    (For experts: if Setting is True, the entry calls Gtk.Window.Activate_Default on the window containing the entry, in the default handler for the "activate" signal.)

  • procedure Set_Width_Chars (The_Entry : access Gtk_Entry_Record'Class; Width : Gint);
    function Get_Width_Chars (The_Entry : access Gtk_Entry_Record'Class) return Gint;
    Number of characters to leave space for in the entry, on the screen. This is the number of visible characters, not the maximal number of characters the entry can contain
  • procedure Set_Text (The_Entry : access Gtk_Entry_Record; Text : UTF8_String);
    function Get_Text (The_Entry : access Gtk_Entry_Record) return UTF8_String;
    Modify the text in the entry. The text is cut at the maximum length that was set when the entry was created. The text replaces the current contents.
  • procedure Set_Alignment (Ent : access Gtk_Entry_Record; Xalign : Gfloat);
    function Get_Alignment (Ent : access Gtk_Entry_Record) return Gfloat;
    Sets the alignment for the contents of the entry. This controls the horizontal positioning of the contents when the displayed text is shorter than the width of the entry.
  • procedure Set_Completion (Ent : access Gtk_Entry_Record; Completion : access Gtk_Entry_Completion_Record'Class);
    function Get_Completion (Ent : access Gtk_Entry_Record) return Gtk_Entry_Completion;
    Sets Completion to be the auxiliary completion object to use with Ent. All further configuration of the completion mechanism is done on Completion using the Gtk.Entry_Completion API.
  • function Text_Index_To_Layout_Index (Ent : access Gtk_Entry_Record; Text_Index : Gint) return Gint;
    Converts from a position in the entry's layout (returned by Get_Layout) to a position in the entry contents (returned by Get_Text). Returns the byte index into the entry layout text
  • function Layout_Index_To_Text_Index (Ent : access Gtk_Entry_Record; Layout_Index : Gint) return Gint;
    Converts from a position in the entry contents (returned by Get_Text) to a position in the entry's layout (returned by Get_Layout, with text retrieved via pango.layout.Get_Text). Return the byte index into the entry contents
  • procedure Get_Layout_Offsets (The_Entry : access Gtk_Entry_Record; X : out Gint; Y : out Gint);
    Obtain the position of the Pango_Layout used to render text in the entry, in widget coordinates. Useful if you want to line up the text in an entry with some other text, e.g. when using the entry to implement editable cells in a sheet widget.

    Also useful to convert mouse events into coordinates inside the Pango_Layout, e.g. to take some action if some part of the entry text is clicked.

    Note that as the user scrolls around in the entry the offsets will change; you'll need to connect to the "notify::scroll_offset" signal to track this. Remember when using the Pango_Layout functions you need to convert to and from pixels using Pango_Pixels or Pango_Scale.

  • function Get_Layout (The_Entry : access Gtk_Entry_Record) return Pango.Layout.Pango_Layout;
    Return the widget that manages all the layout of text (left-to-right, right-to-left, fonts,...). Changing the font used for the entry should be done by changing the font using for this layout. Note that you should also change the font in the Pango_Context returned by Get_Pango_Context, or the next keypress event in the entry will restore the default initial font.

    The layout is useful to e.g. convert text positions to pixel positions, in combination with Get_Layout_Offsets. The returned layout is owned by the entry so need not be freed by the caller.

Signals

  • activate
    procedure Handler (Ent : access Gtk_Entry_Record'Class);
    Called when the entry is activated, for instance when the user presses while in it
  • copy_clipboard
    procedure Handler (Ent : access Gtk_Entry_Record'Class);
    You should emit this signal to request that the current selection be copied into the clipboard. This is mostly used from key bindings.
  • cut_clipboard
    procedure Handler (Ent : access Gtk_Entry_Record'Class);
    You should emit this signal to request that the current selection be deleted and copied into the clipboard. This is mostly used from key bindings.
  • delete_from_cursor
    procedure Handler (Ent : access Gtk_Entry_Record'Class; Step : Gtk_Movement_Step; Amount : Gint);
    You should emit this signal to request that some text be delete from the cursor position.
  • insert_at_cursor
    procedure Handler (Ent : access Gtk_Entry_Record'Class; Text : String);
    You should emit this signal to request that some text be inserted at the current cursor location. This is mostly used from key bindings.
  • move_cursor
    procedure Handler (Ent : access Gtk_Entry_Record'Class; Step : Gtk_Movement_Step; Amount : Gint; Extend_Selection : Boolean);
    You should emit this signal to request that the cursor be moved. This is mostly used when connected to a keybinding, as is done by default for the arrow keys for instance.
  • paste_clipboard
    procedure Handler (Ent : access Gtk_Entry_Record'Class);
    You should emit this signal to request that the clipboard be inserted at the current cursor location. This is mostly used from key bindings.
  • populate_popup
    procedure Handler (Ent : access Gtk_Entry_Record'Class; Menu : access Gtk_Menu_Record'Class);
    ???
  • toggle_overwrite
    procedure Handler (Ent : access Gtk_Entry_Record'Class);
    You should emit this signal to request that the insertion mode be changed. This is mostly used from a key binding, as is done by default for the Insert key.

Properties

  • Activates_Default_Property
    Boolean
    Whether to activate the default widget (such as the default
  • Cursor_Position_Property
    Int
    The current position of the insertion cursor in chars
  • Editable_Property
    Boolean
    Whether the entry contents can be edited
    See: Set_Editable
  • Has_Frame_Property
    Boolean
    FALSE removes outside bevel from entry
  • Invisible_Char_Property
    Gunichar
    The character to use when masking entry contents
  • Max_Length_Property
    Gint
    Maximum number of characters for this entry
    See: Set_Max_Length
  • Scroll_Offset_Property
    Gint
    Number of pixels of the entry scrolled off the screen to the
  • Selection_Bound_Property
    Int
    The position of the opposite end of the selection from the cursor
  • Text_Position_Property
    Gint
    The current position of the insertion point
  • Text_Property
    String
    The contents of the entry
  • Visibility_Property
    Boolean
    FALSE displays the "invisible char" instead of the actual
  • Width_Chars_Property
    Gint
    Number of characters to leave space for in the entry.
    See: Set_Width_Chars
  • Xalign_Property
    Float
    The horizontal alignment, from 0 (left) to 1 (right). Reversed

Testgtk source code

This code is part of testgtk, a demo application packaged with GtkAda. Testgtk demonstrates the various widgets of GtkAda
----------------------------------------------------------------------- -- GtkAda - Ada95 binding for the Gimp Toolkit -- -- -- -- Copyright (C) 1998-1999 -- -- Emmanuel Briot, Joel Brobecker and Arnaud Charlet -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU General Public -- -- License as published by the Free Software Foundation; either -- -- version 2 of the License, or (at your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public -- -- License along with this library; if not, write to the -- -- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- -- Boston, MA 02111-1307, USA. -- -- -- -- -- -- -- -- -- -- ----------------------------------------------------------------------- with Gtk.Box; use Gtk.Box; with Gtk.Check_Button; use Gtk.Check_Button; with Gtk.Combo; use Gtk.Combo; with Gtk.GEntry; use Gtk.GEntry; with Gtk.Enums; use Gtk.Enums; with Gtk.Handlers; use Gtk.Handlers; with Gtk; use Gtk; package body Create_Entry is package Entry_Cb is new Handlers.User_Callback (Gtk_Check_Button_Record, Gtk_Entry); ---------- -- Help -- ---------- function Help return String is begin return "This demo demonstrates two types of widgets, a simple" & " @bGtk_Entry@B and a @bGtk_Combo@B that is composed that adds a" & " window to facilitates the insertion of the text."; end Help; --------------------- -- Toggle_Editable -- --------------------- procedure Toggle_Editable (Button : access Gtk_Check_Button_Record'Class; The_Entry : Gtk_Entry) is begin Set_Editable (The_Entry, Get_Active (Button)); end Toggle_Editable; ---------------------- -- Toggle_Sensitive -- ---------------------- procedure Toggle_Sensitive (Button : access Gtk_Check_Button_Record'Class; The_Entry : Gtk_Entry) is begin Set_Sensitive (The_Entry, Get_Active (Button)); end Toggle_Sensitive; ----------------------- -- Toggle_Visibility -- ----------------------- procedure Toggle_Visibility (Button : access Gtk_Check_Button_Record'Class; The_Entry : in Gtk_Entry) is begin Set_Visibility (The_Entry, Get_Active (Button)); end Toggle_Visibility; --------- -- Run -- --------- procedure Run (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is use String_List; List : String_List.Glist; Box1, Box2 : Gtk_Box; The_Entry : Gtk_Entry; Combo : Gtk_Combo; Check : Gtk_Check_Button; begin Append (List, "item0"); Append (List, "item1 item1"); Append (List, "item2 item2 item2"); Append (List, "item3 item3 item3 item3"); Append (List, "item4 item4 item4 item4 item4"); Append (List, "item5 item5 item5 item5 item5 item5"); Append (List, "item6 item6 item6 item6 item6"); Append (List, "item7 item7 item7 item7"); Append (List, "item8 item8 item8"); Append (List, "item9 item9"); Set_Label (Frame, "Entry"); Gtk_New_Vbox (Box1, False, 0); Add (Frame, Box1); Gtk_New_Vbox (Box2, False, 10); Set_Border_Width (Box2, 10); Pack_Start (Box1, Box2, False, False, 0); Gtk_New (The_Entry); Set_Text (The_Entry, "Hello world"); Pack_Start (Box2, The_Entry, True, True, 0); Gtk_New (Combo); Set_Popdown_Strings (Combo, List); Set_Text (Get_Entry (Combo), "hello world"); Pack_Start (Box2, Combo, True, True, 0); Gtk_New (Check, "Editable"); Pack_Start (Box2, Check, False, True, 0); Entry_Cb.Connect (Check, "toggled", Entry_Cb.To_Marshaller (Toggle_Editable'Access), The_Entry); Set_Active (Check, True); Gtk_New (Check, "Visible"); Pack_Start (Box2, Check, False, True, 0); Entry_Cb.Connect (Check, "toggled", Entry_Cb.To_Marshaller (Toggle_Visibility'Access), The_Entry); Set_Active (Check, True); Gtk_New (Check, "Sensitive"); Pack_Start (Box2, Check, False, True, 0); Entry_Cb.Connect (Check, "toggled", Entry_Cb.To_Marshaller (Toggle_Sensitive'Access), The_Entry); Set_Active (Check, True); Show_All (Frame); end Run; end Create_Entry;

Alphabetical Index