/* Copyright 1998 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/****************************************************************************
 * This source file was written by Acorn Computers Limited. It is part of   *
 * the toolbox library for writing desktop applications in C. It may be     *
 * used freely in the creation of programs for RISC OS.                     *
 *                                                                          *
 * Copyright  Acorn Computers Ltd, 1998                                    *
 *                                                                          *
 ***************************************************************************/



/*
 * Name        : textarea.h
 * Description : C veneers to the Methods provided by the textarea gadget
 */



#ifndef __textarea_h
#define __textarea_h


#ifndef __kernel_h
#include "kernel.h"
#endif

#ifndef __toolbox_h
#include "toolbox.h"
#endif

#ifndef __window_h
#include "window.h"
#endif


/****************************************************************************
 * TextArea Templates                                                       *
 ****************************************************************************/

/*-- flags --*/

#define TextArea_Scrollbar_Vertical	0x00000001
#define TextArea_Scrollbar_Horizontal	0x00000002
#define TextArea_WordWrap		0x00000004

#define TextAreaValidFlags	        0xC0000007

/*-- templates --*/

typedef struct
{
    GadgetHeader	hdr;
    int			type;
    int			event;
    char		*text;
    unsigned int	foreground;
    unsigned int	background;
} TextArea;


/*-- TextArea methods --*/

#define TextArea_Base		0x4018
#define TextArea_Type		(sizeof(TextArea)) << 16 | TextArea_Base
#define TextArea_SWIBase	0x140180

#define TextArea_GetState	     (TextArea_Base + 0)
#define TextArea_SetState	     (TextArea_Base + 1)
#define TextArea_SetText	     (TextArea_Base + 2)
#define TextArea_GetText	     (TextArea_Base + 3)
#define TextArea_InsertText	     (TextArea_Base + 4)
#define TextArea_ReplaceText	     (TextArea_Base + 5)
#define TextArea_GetSelection	     (TextArea_Base + 6)
#define TextArea_SetSelection	     (TextArea_Base + 7)
#define TextArea_SetFont	     (TextArea_Base + 8)
#define TextArea_SetColour	     (TextArea_Base + 9)
#define TextArea_GetColour	     (TextArea_Base + 10)
#define TextArea_SetCursorPosition   (TextArea_Base + 11)
#define TextArea_GetCursorPosition   (TextArea_Base + 12)


/*-- TextArea events --*/

/*-- TextArea SWI method constants --*/

#define TextArea_DesktopColours	(1<<0)



/****************************************************************************
 * The following functions provide veneers to the methods that are          *
 * associated with this particular class.  Please read the C Release 5      *
 * user guide for more detailed information on their functionality.         *
 ****************************************************************************/


#ifdef __cplusplus
  extern "C" {
#endif


/*
 * Name        : textarea_replace_text
 * Description : Replaces a block of text with new text in a specified textarea
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId textarea
 *               unsigned int index_start
 *               unsigned int index_end
 *               const char *text
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_replace_text ( unsigned int flags,
                                                ObjectId window,
                                                ComponentId textarea,
                                                unsigned int index_start,
                                                unsigned int index_end,
                                                const char *text
                                              );


/*
 * Name        : textarea_insert_text
 * Description : Inserts text at a specified offset into the specified textarea
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId textarea
 *               unsigned int index
 *               const char *text
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_insert_text ( unsigned int flags,
                                               ObjectId window,
                                               ComponentId textarea,
                                               unsigned int index,
                                               const char *text
                                             );


/*
 * Name        : textarea_set_state
 * Description : Sets the state of the specified textarea.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId textarea
 *               unsigned int state
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_set_state ( unsigned int flags,
                                             ObjectId window,
                                             ComponentId textarea,
                                             unsigned int state
                                           );


/*
 * Name        : textarea_get_state
 * Description : Gets the state of the specified textarea.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId textarea
 * Out         : unsigned int *state
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_get_state ( unsigned int flags,
                                             ObjectId window,
                                             ComponentId textarea,
                                             unsigned int *state
                                           );


/*
 * Name        : textarea_get_selection_text
 * Description : Gets the selected text of the specified textarea.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId textarea
 *               char *buffer
 *               int size
 * Out         : unsigned int *nbytes
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_get_selection_text ( unsigned int flags,
                                                      ObjectId window,
                                                      ComponentId textarea,
                                                      char *buffer,
                                                      int size,
                                                      unsigned int *nbytes
                                                    );


/*
 * Name        : textarea_set_selection
 * Description : Sets the selection for the specified textarea.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId textarea
 *               unsigned int index_start
 *               unsigned int index_end
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_set_selection ( unsigned int flags,
                                                 ObjectId window,
                                                 ComponentId textarea,
                                                 unsigned int index_start,
                                                 unsigned int index_end
                                               );


/*
 * Name        : textarea_get_selection_points
 * Description : Gets the selection points for the specified textarea.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId textarea
 * Out         : unsigned int *index_start
 *               unsigned int *index_end
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_get_selection_points ( unsigned int flags,
                                                        ObjectId window,
                                                        ComponentId textarea,
                                                        unsigned int *index_start,
                                                        unsigned int *index_end
                                                      );


/*
 * Name        : textarea_set_colour
 * Description : Sets the colours for the specified textarea.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId textarea
 *               unsigned int foreground
 *               unsigned int background
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_set_colour ( unsigned int flags,
                                              ObjectId window,
                                              ComponentId textarea,
                                              unsigned int foreground,
                                              unsigned int background
                                            );


/*
 * Name        : textarea_get_colour
 * Description : Gets the colours currently being used for the specified textarea.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId textarea
 * Out         : unsigned int *foreground
 *               unsigned int *background
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_get_colour ( unsigned int flags,
                                              ObjectId window,
                                              ComponentId textarea,
                                              unsigned int *foreground,
                                              unsigned int *background
                                            );


/*
 * Name        : textarea_get_text
 * Description : Gets the text that is current displayed in the specified textarea.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId writable
 *               char *buffer
 *               int buff_size
 * Out         : int *nbytes
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_get_text ( unsigned int flags,
                                            ObjectId window,
                                            ComponentId writable,
                                            char *buffer,
                                            int buff_size,
                                            int *nbytes
                                          );


/*
 * Name        : textarea_set_text
 * Description : Sets the text string to be shown in the specified textarea
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId writable
 *               const char *text
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_set_text ( unsigned int flags,
                                            ObjectId window,
                                            ComponentId writable,
                                            const char *text
                                          );


/*
 * Name        : textarea_set_font
 * Description : Set the font for the specified textarea.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId textarea
 *               const char *font_name
 *               unsigned int width
 *               unsigned int height
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_set_font ( unsigned int flags,
                                            ObjectId window,
                                            ComponentId textarea,
                                            const char *font_name,
                                            unsigned int width,
                                            unsigned int height
                                          );


/*
 * Name        : textarea_set_cursor_position
 * Description : Sets the cursor position in a textarea
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId textarea
 *               int index
 *               int *old_index
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_set_cursor_position ( unsigned int flags,
                                                       ObjectId window,
                                                       ComponentId textarea,
                                                       unsigned int index,
                                                       unsigned int *old_index
                                                     );


/*
 * Name        : textarea_get_cursor_position
 * Description : Gets the cursor position in a textarea
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId textarea
 *               unsigned int *index
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *textarea_get_cursor_position ( unsigned int flags,
                                                       ObjectId window,
                                                       ComponentId textarea,
                                                       unsigned int *index
                                                     );


#ifdef __cplusplus
  }
#endif




#endif
