Home modules.gotpike.org
Username: Password: [Create Account]
[Forgot Password?]

Modules

ADT
Database
GTK2
GUI
IP
PiJAX
Public
Sql
Stdio
Subversion
System
Tools
Xosd
lua
v4l2
wx

Recent Changes

Public.Parser.XML2 1.50
Public.ZeroMQ 1.1
Public.Template.Mustache 1.0
Public.Protocols.XMPP 1.4
Sql.Provider.jdbc 1.0

Popular Downloads

Public.Parser.JSON2 1.0
Public.Parser.JSON 0.2
GTK2 2.23
Public.Web.FCGI 1.8
Public.Parser.XML2 1.48


Module Information
GUI.GTK2
Viewing contents of GUI_GTK2-0.1/entry.cmod

#include "global.h"
#include "svalue.h"
#include "interpret.h"

#include 

/* This must be included last! */
#include "module.h"

#include "gtk2.h"


/*! @module GUI */
/*! @module GTK2 */
/*! @class Entry
 *! 
 *! a single line text entry field
 *!
 *! @b{ Object Hierarchy @}
 *!
 *! @[Object] -> @[Widget] -> Entry
 *!
 *!
 *! @b{ Signal Prototypes @}
 *!
 *! @i{"activate"@} void user_function (Entry entry, mixed user_data)
 *!
 *! @i{"backspace"@} void user_function (Entry entry, mixed user_data)
 *!
 *! @i{"copy-clipboard"@} void user_function (Entry entry, mixed user_data)
 *!
 *! @i{"cut-clipboard"@} void user_function (Entry entry, mixed user_data)
 */

PIKECLASS Entry
 program_flags PROGRAM_USES_PARENT;
{
  INHERIT Widget;

  /*! @decl void create()
   *! 
   *! creates a new Entry
   */
  PIKEFUN void create()
  {
    GTK2_LOW=(void*)gtk_entry_new();
  }

  /*! @decl void set_text(string text)
   *! 
   *! Sets the text in the Entry to the given value, replacing the current contents.
   *!
   *! @param text
   *!    the new text
   */
  PIKEFUN void set_text(string text)
  {
    f_string_to_utf8(1);
    gtk_entry_set_text(GTK_ENTRY(GTK2_LOW),Pike_sp[-1].u.string->str);
    pop_n_elems(args);
  }

  /*! @decl string get_text()
   *!
   *! Retrieves the contents of the entry widget
   */
  PIKEFUN string get_text()
  {
    const gchar* chr=gtk_entry_get_text(GTK_ENTRY(GTK2_LOW));
    push_string(make_shared_binary_string(chr,strlen(chr)));
    f_utf8_to_string(1); 
  }

  /*! @decl void set_visibility(int(0..1) visible)
   *!
   *! Sets whether the contents of the entry are visible or not. When@
   *! visibility is set to 0, characters are displayed as the invisible@
   *! char, and will also appear that way when the text in the entry@
   *! widget is copied elsewhere.
   *!
   *! The default invisible char is the asterisk '*', but it can be@
   *! changed with @[set_invisible_char()].
   */
  PIKEFUN void set_visibility(int(0..1) visible)
  {
    gtk_entry_set_visibility(GTK_ENTRY(GTK2_LOW),visible);
    pop_n_elems(args);
  }

  /*! @decl void set_invisible_char(int ch)
   *!
   *! Sets the character to use in place of the actual text when@
   *! @[set_visibility()] has been called to set text visibility@
   *! to 0. 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.
   *!
   *! @param ch
   *!    a character
   */
  PIKEFUN void set_invisible_char(int ch)
  {
    gtk_entry_set_invisible_char(GTK_ENTRY(GTK2_LOW),(gunichar)ch);
    pop_n_elems(args);
  }

  /*! @decl void set_max_length(int len)
   *!
   *! Sets the maximum allowed length of the contents of the widget.@
   *! If the current contents are longer than the given length, then@
   *! they will be truncated to fit.
   *!
   *! @param len
   *!     the maximum length of the entry, or 0 for no maximum.@
   *!     (other than the maximum length of entries.) The value@
   *!     passed in will be clamped to the range 0-65536.
   */
  PIKEFUN void set_max_length(int l)
  {
    gtk_entry_set_max_length(GTK_ENTRY(GTK2_LOW),l);
    pop_n_elems(args);
  }

  /*! @decl int(0..1) get_has_frame()
   *!
   *! Gets the value set by @[set_has_frame()]
   *!
   *! @returns
   *!     whether the entry has a beveled frame
   */
  PIKEFUN int(0..1) get_has_frame()
  {
    gint i=gtk_entry_get_has_frame(GTK_ENTRY(GTK2_LOW));
    RETURN(i);
  }

  /*! @decl void set_has_frame(int setting)
   *!
   *! Sets whether the entry has a beveled frame around it
   *!
   *! @param setting
   *!    new value
   */
  PIKEFUN void set_has_frame(int setting)
  {
    gtk_entry_set_has_frame(GTK_ENTRY(GTK2_LOW),setting);
    pop_n_elems(args);
  }

  /*! @decl int get_invisible_char()
   *!
   *! Retrieves the character displayed in place of the real characters@
   *! for entries with visibility set to false
   *!
   *! @returns
   *!     the current invisible char, or 0, if the entry does not show@
   *!     invisible text at all.
   */
  PIKEFUN int get_invisible_char()
  {
    gunichar ch=gtk_entry_get_invisible_char(GTK_ENTRY(GTK2_LOW));
    RETURN ch;
  }

  /*! @decl void set_alignment(int xalign)
   *!
   *! 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.
   *!
   *! @param xalign
   *!    The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL layouts 
   */
  PIKEFUN void set_alignment(float xalign)
  {
    gtk_entry_set_alignment(GTK_ENTRY(GTK2_LOW),xalign);
    pop_n_elems(args);
  }

  /*! @decl float get_alignment()
   *!
   *! Gets the value set by @[set_alignment()].
   *!
   *! @returns
   *!    the alignment
   */
  PIKEFUN float get_alignment()
  {
    gfloat f=gtk_entry_get_alignment(GTK_ENTRY(GTK2_LOW));
    RETURN f;
  }

  /*! @decl int get_max_length()
   *!
   *! Retrieves the maximum allowed length of the text in entry.@
   *! See @[set_max_length()].
   *!
   *! @returns
   *!    the maximum allowed number of characters in Entry, or 0@
   *!    if there is no maximum.
   */
  PIKEFUN int get_max_length()
  {
    gint i=gtk_entry_get_max_length(GTK_ENTRY(GTK2_LOW));
    RETURN i;
  }

  /*! @decl int(0..1) get_visibility()
   *!
   *! Retrieves whether the text in entry is visible.@
   *! See @[set_visibility()].
   *!
   *! @returns
   *!    1 if the text ist currently visible, 0 otherwise
   */
  PIKEFUN int(0..1) get_visibility()
  {
    gboolean b=gtk_entry_get_visibility(GTK_ENTRY(GTK2_LOW));
    RETURN b?1:0;
  }


  INIT
  {
  }

  EXIT
  {
  }

}

/*! @endclass */
/*! @endmodule */
/*! @endmodule */

void pike_init_gtk2_entry(void)
{
  INIT
}

void pike_exit_gtk2_entry(void)
{
  EXIT
}


gotpike.org | Copyright © 2004 - 2019 | Pike is a trademark of Department of Computer and Information Science, Linköping University