/* Copyright 1997 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, 1994                                    *
 *                                                                          *
 ***************************************************************************/



/*
 * Name        : scale.h
 * Description : C veneers to the Methods provided by the scale class
 */



#ifndef __scale_h
#define __scale_h


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

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

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

/****************************************************************************
 * Scale Templates                                                          *
 ****************************************************************************/

/*-- flags --*/

#define Scale_GenerateShowEvent    0x00000001
#define Scale_GenerateHideEvent    0x00000002
#define Scale_IncludeScaleToFit    0x00000004


/*-- templates --*/

typedef struct
{
  unsigned int   flags;
  int            min_value;
  int            max_value;
  int            step_size;
  char           *title;
  int            max_title;
  char           *window;
  int            std_value[4];
} ScaleTemplate;


/****************************************************************************
 * Scale SWI Calls                                                          *
 ****************************************************************************/

#define Scale_SWIChunkBase    0x82c00
#define Scale_ObjectClass     Scale_SWIChunkBase
#define Scale_ClassSWI        (Scale_SWIChunkBase + 0)
#define Scale_PostFilter      (Scale_SWIChunkBase + 1)
#define Scale_PreFilter       (Scale_SWIChunkBase + 2)

/****************************************************************************
 * Scale SWI constants                                                      *
 ****************************************************************************/

#define Scale_SetLowerBound             0x00000001
#define Scale_SetUpperBound             0x00000002
#define Scale_SetStepSize               0x00000004

/****************************************************************************
 * Scale Methods                                                            *
 ****************************************************************************/

#define Scale_GetWindowId           0
#define Scale_SetValue              1
#define Scale_GetValue              2
#define Scale_SetBounds             3
#define Scale_GetBounds             4
#define Scale_SetTitle              5
#define Scale_GetTitle              6


/****************************************************************************
 * Scale Toolbox Events                                                     *
 ****************************************************************************/

#define Scale_AboutToBeShown     Scale_SWIChunkBase
#define Scale_DialogueCompleted  (Scale_SWIChunkBase + 1)
#define Scale_ApplyFactor        (Scale_SWIChunkBase + 2)


typedef struct
{
  ToolboxEventHeader hdr;
  int                show_type;
  union
  {
    TopLeft               pos;
    WindowShowObjectBlock full;
  } info;
} ScaleAboutToBeShownEvent;


typedef struct
{
  ToolboxEventHeader hdr;
} ScaleDialogueCompletedEvent;


typedef struct
{
  ToolboxEventHeader hdr;
  unsigned int       factor;
} ScaleApplyFactorEvent;




/****************************************************************************
 * The following functions provide veneers to the methods that are          *
 * associated with this particular class.  Please read the User Interface   *
 * Toolbox manual for more detailed information on their functionality.     *
 ****************************************************************************/



#ifdef __cplusplus
  extern "C" {
#endif


/*
 * Name        : scale_get_title
 * Description : Gets the title for the specified scale object
 * In          : unsigned int flags
 *               ObjectId scale
 *               char *buffer
 *               int buff_size
 * Out         : int *nbytes
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scale_get_title ( unsigned int flags,
                                          ObjectId scale,
                                          char *buffer,
                                          int buff_size,
                                          int *nbytes
                                        );


/*
 * Name        : scale_set_title
 * Description : Sets the title for the specifed scale object
 * In          : unsigned int flags
 *               ObjectId scale
 *               const char *title
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scale_set_title ( unsigned int flags,
                                          ObjectId scale,
                                          const char *title
                                        );


/*
 * Name        : scale_get_bounds
 * Description : Gets the bounds and/or step size for the specified scale object
 * In          : unsigned int flags
 *               ObjectId scale
 * Out         : int *lower_bound
 *               int *upper_bound
 *               int *step_size
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scale_get_bounds ( unsigned int flags,
                                           ObjectId scale,
                                           int *lower_bound,
                                           int *upper_bound,
                                           int *step_size
                                         );


/*
 * Name        : scale_set_bounds
 * Description : Sets the bounds and/or step size for the specified scale object
 * In          : unsigned int flags
 *               ObjectId scale
 *               int lower_bound
 *               int upper_bound
 *               int step_size
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scale_set_bounds ( unsigned int flags,
                                           ObjectId scale,
                                           int lower_bound,
                                           int upper_bound,
                                           int step_size
                                         );


/*
 * Name        : scale_get_value
 * Description : Gets the scale factor value for the specified scale object
 * In          : unsigned int flags
 *               ObjectId scale
 * Out         : int *value
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scale_get_value ( unsigned int flags,
                                          ObjectId scale,
                                          int *value
                                        );


/*
 * Name        : scale_set_value
 * Description : Sets the scale factor value for the specified scale object
 * In          : unsigned int flags
 *               ObjectId scale
 *               int value
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scale_set_value ( unsigned int flags,
                                          ObjectId scale,
                                          int value
                                        );


/*
 * Name        : scale_get_window_id
 * Description : Gets the id of the underlying window object for the scale object
 * In          : unsigned int flags
 *               ObjectId scale
 * Out         : ObjectId *window
 * Returns     : pointer to error block
 */

extern _kernel_oserror *scale_get_window_id ( unsigned int flags,
                                              ObjectId scale,
                                              ObjectId *window
                                            );


#ifdef __cplusplus
  }
#endif



#endif
