/* 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        : scrollbar.h
 * Description : C veneers to the Methods provided by the scrollbar gadget
 */



#ifndef __scrollbar_h
#define __scrollbar_h


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

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

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


/****************************************************************************
 * ScrollBar Templates                                                      *
 ****************************************************************************/

/*-- flags --*/

#define Scrollbar_Vertical	0x00000000
#define Scrollbar_Horizontal	0x00000001

#define ScrollbarValidFlags	0xC0000001

/*-- templates --*/

typedef struct
{
    GadgetHeader	hdr;
    int			type;
    int			event;
    unsigned int	min;
    unsigned int	max;
    unsigned int	value;
    unsigned int	visible;
    unsigned int	line_inc;
    unsigned int	page_inc;
} Scrollbar;


/*-- ScrollBar methods --*/

#define Scrollbar_Base		0x401B
#define Scrollbar_Type		(sizeof(Scrollbar)) << 16 | Scrollbar_Base
#define Scrollbar_SWIBase	0x140183

#define Scrollbar_GetState	(Scrollbar_Base + 0)
#define Scrollbar_SetState	(Scrollbar_Base + 1)
#define Scrollbar_SetBounds	(Scrollbar_Base + 2)
#define Scrollbar_GetBounds	(Scrollbar_Base + 3)
#define Scrollbar_SetValue	(Scrollbar_Base + 4)
#define Scrollbar_GetValue	(Scrollbar_Base + 5)
#define Scrollbar_SetIncrements	(Scrollbar_Base + 6)
#define Scrollbar_GetIncrements	(Scrollbar_Base + 7)
#define Scrollbar_SetEvent	(Scrollbar_Base + 8)
#define Scrollbar_GetEvent	(Scrollbar_Base + 9)


/*-- ScrollBar events --*/
#define Scrollbar_PositionChanged	(Scrollbar_SWIBase)

typedef struct
{
    ToolboxEventHeader	hdr;
    unsigned int	new_position;
    int			direction;
} ScrollbarPositionChangedEvent;

/*-- Scrollbar SWI method constants --*/

#define Scrollbar_Lower_Bound	(1<<0)
#define Scrollbar_Upper_Bound	(1<<1)
#define Scrollbar_Visible_Len	(1<<2)

#define Scrollbar_Line_Inc	(1<<0)
#define Scrollbar_Page_Inc	(1<<1)


/****************************************************************************
 * 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        : scrollbar_get_state
 * Description : Gets the state of the specified scrollbar.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId scrollbar
 * Out         : unsigned int *state
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scrollbar_get_state ( unsigned int flags,
                                              ObjectId window,
                                              ComponentId scrollbar,
                                              unsigned int *state
                                            );


/*
 * Name        : scrollbar_get_increments
 * Description : Gets the increments for the specified scrollbar.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId scrollbar
 * Out         : unsigned int *line_inc
 *               unsigned int *page_inc
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scrollbar_get_increments ( unsigned int flags,
                                                   ObjectId window,
                                                   ComponentId scrollbar,
                                                   unsigned int *line_inc,
                                                   unsigned int *page_inc
                                                 );


/*
 * Name        : scrollbar_set_increments
 * Description : Sets the increments for the specified scrollbar.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId scrollbar
 *               unsigned int line_inc
 *               unsigned int page_inc
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scrollbar_set_increments ( unsigned int flags,
                                                   ObjectId window,
                                                   ComponentId scrollbar,
                                                   unsigned int line_inc,
                                                   unsigned int page_inc
                                                 );


/*
 * Name        : scrollbar_get_bounds
 * Description : Gets the bounds for the specified scrollbar.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId scrollbar
 * Out         : unsigned int *lower_bound
 *               unsigned int *upper_bound
 *               unsigned int *visible_len
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scrollbar_get_bounds ( unsigned int flags,
                                               ObjectId window,
                                               ComponentId scrollbar,
                                               unsigned int *lower_bound,
                                               unsigned int *upper_bound,
                                               unsigned int *visible_len
                                             );


/*
 * Name        : scrollbar_set_bounds
 * Description : Sets the bounds for the specified scrollbar.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId scrollbar
 *               unsigned int lower_bound
 *               unsigned int upper_bound
 *               unsigned int visible_len
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scrollbar_set_bounds ( unsigned int flags,
                                               ObjectId window,
                                               ComponentId scrollbar,
                                               unsigned int lower_bound,
                                               unsigned int upper_bound,
                                               unsigned int visible_len
                                             );


/*
 * Name        : scrollbar_get_event
 * Description : Gets the event returned by the specified scrollbar.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId scrollbar
 * Out         : unsigned int *event
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scrollbar_get_event ( unsigned int flags,
                                              ObjectId window,
                                              ComponentId scrollbar,
                                              unsigned int *event
                                            );


/*
 * Name        : scrollbar_get_value
 * Description : Gets the position of the specified scrollbar.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId scrollbar
 * Out         : unsigned int *value
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scrollbar_get_value ( unsigned int flags,
                                              ObjectId window,
                                              ComponentId scrollbar,
                                              unsigned int *value
                                            );


/*
 * Name        : scrollbar_set_event
 * Description : Sets the event generated by the specified scrollbar.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId scrollbar
 *               unsigned int event
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scrollbar_set_event ( unsigned int flags,
                                              ObjectId window,
                                              ComponentId scrollbar,
                                              unsigned int event
                                            );


/*
 * Name        : scrollbar_set_value
 * Description : Sets the scroll offset for the specified scrollbar.
 * In          : unsigned int flags
 *               ObjectId window
 *               ComponentId scrollbar
 *               unsigned int new_value
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scrollbar_set_value ( unsigned int flags,
                                              ObjectId window,
                                              ComponentId scrollbar,
                                              unsigned int new_value
                                            );


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

extern _kernel_oserror *scrollbar_set_state ( unsigned int flags,
                                              ObjectId window,
                                              ComponentId scrollbar,
                                              unsigned int state
                                            );


#ifdef __cplusplus
  }
#endif


#endif
