/* 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.
 */
/***************************************************/
/* File   : Toolbars.h                             */
/*                                                 */
/* Purpose: Toolbar-related functions for the      */
/*          browser.                               */
/*                                                 */
/* Author : A.D.Hodgkinson                         */
/*                                                 */
/* History: 21-Nov-96: Created.                    */
/*          25-Aug-97: Definitions imported from   */
/*                     TBEvents.h.                 */
/***************************************************/

/* URL bar definitions */

#define DisplayURL         0x000b /* URL display / writable                             */
#define DisplayMenu        0x000c /* History menu next to URL writable                  */
#define DisplayMLeft       0x3201 /* History menu button object, to pop menu up to left */
#define URLSpacer          0x000d /* Invisible icon to mark height of bar               */
#define DiallerStatus      0x0012 /* Display field for dialler status (optional gadget) */
#define DiallerCover       0x0013 /* Gadget covering dialler display                    */
#define DiallerLabel       0x0014 /* Label on dialler display                           */

/* Button bar definitions */

#define ButtonHome         0x0000 /* Go to home page                                    */
#define ButtonBack         0x0001 /* Return to previous page in history (if available)  */
#define ButtonReload       0x0002 /* Reload page                                        */
#define ButtonStop         0x0003 /* Stop any current fetch                             */
#define ButtonForward      0x0004 /* Go to next page in history list (if available)     */
#define ButtonAddHot       0x0005 /* Add the URL to the Hotlist                         */
#define ButtonViewHot      0x0006 /* View the hotlist                                   */
#define ButtonViewRes      0x0007 /* View the resource list                             */
#define ButtonLoadImg      0x0008 /* Load images (if they weren't loaded automatically) */
#define ButtonViewSrc      0x0009 /* View the page source                               */
#define ButtonSpacer       0x000E /* Invisible icon to mark height of bar               */
#define ButtonGoTo         0x000F /* Go To button (allows entry of a URL)               */
#define ButtonGo           0x0010 /* Go (companion to above, jumps to URL)              */
#define ButtonCancel       0x0011 /* Cancel a current action                            */
#define ButtonBi           0x0015 /* The working gadget of a bistate group of 3.        */
#define ButtonTri          0x0016 /* The working gadget of a tristate group of 4.       */

/* (Button bar events) */

#define EButtonHome        0x0200
#define EButtonBack        0x0201
#define EButtonReload      0x0202
#define EButtonStop        0x0203
#define EButtonForward     0x0204
#define EButtonAddHot      0x0205
#define EButtonViewHot     0x0206
#define EButtonViewRes     0x0207
#define EButtonLoadImg     0x0208
#define EButtonViewSrc     0x0209
#define EButtonGoTo        0x020A /* Go To button (allows entry of a URL).            */
#define EButtonGo          0x020B /* Go (companion to above, jumps to URL).           */
#define EButtonCancel      0x020C /* Cancel a current action.                         */

#define EBiStateKeyed      0x020D /* Bistate button to be activated [from keyboard].  */
#define ETriStateKeyed     0x020E /* Tristate button to be activated [from keyboard]. */

/* Status bar definitions */

#define DisplayBase        0x3100 /* Animation base (static) sprite       */
#define DisplayAnim        0x3101 /* Animation main (moving) sprite       */
#define DisplayStats       0x3102 /* Main status display field            */
#define DisplayBytes       0x3103 /* Byte counter display field           */
#define StatusSpacer       0x3104 /* Invisible icon to mark height of bar */
#define StatsCover         0x3105 /* Gadget covering status display       */
#define BytesCover         0x3106 /* Gadget covering bytes display        */
#define StatusLabel        0x3107 /* Label on status display              */

/* Magic number definitions */

#define InternalBottomLeft 1
#define InternalTopLeft    2
#define ExternalBottomLeft 4
#define ExternalTopLeft    8

/* The range of messages that can be in the status bar. */
/* These are defined in order of priority, the first    */
/* having the lowest. Items which decay are not worked  */
/* out by toolbars_update_status, and must be set       */
/* explicitly with toolbars_update_specific_status.     */

typedef enum status_type
{
  Toolbars_Status_NoType = -1, /* To indicate no current status at all */
  Toolbars_Status_Ready,       /* Just 'ready', no other info          */
  Toolbars_Status_Viewing,     /* Viewing '(URL / title)'              */
  Toolbars_Status_Formatting,  /* Formatting '(URL)'                   */
  Toolbars_Status_Processing,  /* Processing '(URL)'                   */
  Toolbars_Status_GetPics,     /* Number of images being fetched       */
  Toolbars_Status_Fetching,    /* Fetching '(URL)'                     */
  Toolbars_Status_LinkTo,      /* Showing a link to something (decays) */
  Toolbars_Status_Help         /* Showing interactive help (decays)    */
}
status_type;

/* Function prototypes */

ObjectId          toolbars_get_upper              (browser_data * b);
ObjectId          toolbars_get_lower              (browser_data * b);

void              toolbars_set_presence           (browser_data * b, unsigned int flags);
void              toolbars_move_gadgets           (browser_data * p);

int               toolbars_animation              (int eventcode, WimpPollBlock * b, IdBlock * idb, browser_data * handle);
int               toolbars_animation_drift        (int eventcode, WimpPollBlock * b, IdBlock * idb, browser_data * handle);
int               toolbars_animate_slow           (int eventcode, WimpPollBlock * b, IdBlock * idb, void * handle);

void              toolbars_hide_cgi               (char * url);
void              toolbars_hide_internal          (char * iurl);

_kernel_oserror * toolbars_update_status          (browser_data * b, status_type type);
_kernel_oserror * toolbars_cancel_status          (browser_data * b, status_type type);
int               toolbars_timeout_status         (int eventcode, WimpPollBlock * b, IdBlock * idb, browser_data * handle);
_kernel_oserror * toolbars_remove_status_item     (browser_data * b, browser_data * ancestor);

void              toolbars_update_progress        (browser_data * b);
void              toolbars_update_url             (browser_data * b);
_kernel_oserror * toolbars_update_dialler_time    (browser_data * b);
_kernel_oserror * toolbars_update_dialler_status  (browser_data * b);

int               toolbars_button_height          (browser_data * b);
int               toolbars_url_height             (browser_data * b);
int               toolbars_status_height          (browser_data * b);

_kernel_oserror * toolbars_set_button_states      (browser_data * b);
_kernel_oserror * toolbars_set_all_button_states  (void);

void              toolbars_merged_to_status       (browser_data * b, ObjectId t);
void              toolbars_merged_to_url          (browser_data * b, ObjectId t);
void              toolbars_set_bistate_state      (browser_data * b, ObjectId t, int state);
void              toolbars_set_tristate_state     (browser_data * b, ObjectId t, int state);