;;;;
;;;; entry.stk  -- GTK Entry Widget
;;;;
;;;; Copyright © 2001-2021 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;;
;;;;
;;;; This program 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 program 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 program; if not, write to the Free Software
;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
;;;; USA.
;;;;
;;;;           Author: Erick Gallesio [eg@unice.fr]
;;;;    Creation date: 24-Jul-2001 18:05 (eg)
;;;;


;;;;
;;;; GTK Bindings
;;;;
(define-gtk gtk-entry-new() :pointer                            "gtk_entry_new")
(define-gtk gtk-editable-get-position (:pointer) :int           "gtk_editable_get_position")
(define-gtk gtk-editable-set-position (:pointer :int) :void     "gtk_editable_set_position")
(define-gtk gtk-editable-set-editable (:pointer :boolean) :void "gtk_editable_set_editable")
(define-gtk gtk-editable-get-editable (:pointer) :boolean       "gtk_editable_get_editable")

;======================================================================
;
;                < E n t r y >
;
;======================================================================
(define-class <entry> (<gtk-widget>)
  ((cursor-position #:accessor       cursor-position
                    #:init-keyword   #:cursor-position
                    #:allocation     #:virtual
                    #:slot-ref       (lambda (o)
                                       (gtk-editable-get-position
                                        (slot-ref o 'wid)))
                    #:slot-set!      (lambda (o v)
                                       (gtk-editable-set-position
                                        (slot-ref o 'wid) v)))
   (max-length      #:accessor       max-length
                    #:init-keyword   #:max-length
                    #:allocation     #:gtk-property)
   (text-visibility #:accessor       text-visibility
                    #:init-keyword   #:text-visibility
                    #:allocation     #:gtk-property
                    #:gtk-name       "visibility")
   (text-editable   #:accessor       text-editable
                    #:init-keyword   #:text-editable
                    #:allocation     #:virtual ;; since the GTK property doesn't seems to work
                    #:slot-ref       (lambda (o)
                                       (gtk-editable-get-editable (slot-ref o 'wid)))
                    #:slot-set!      (lambda (o v)
                                       (gtk-editable-set-editable (slot-ref o 'wid) v)))
   (value           #:accessor       value
                    #:init-keyword   #:value
                    #:allocation     #:gtk-property
                    #:gtk-name       "text")))

(define-method realize-widget ((self <entry>) initargs)
  (let ((e (gtk-entry-new)))
    (cpointer-type-set! e 'gtk-entry)
    (slot-set! self 'wid e)))


;;;
;;; Module exports
;;;
(export <entry> cursor-position max-length text-visibility text-editable value)
