/* 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.                 */
/***************************************************/

/* Button bar component IDs */

#define ButtonBarHome                   0x00001 /* Go to home page                                     */
#define ButtonBarBack                   0x00002 /* Return to previous page in history (if available)   */
#define ButtonBarReload                 0x00003 /* Reload page                                         */
#define ButtonBarStop                   0x00004 /* Stop any current fetch                              */
#define ButtonBarForward                0x00005 /* Go to next page in history list (if available)      */
#define ButtonBarAddToHotlist           0x00006 /* Add the URL to the Hotlist                          */
#define ButtonBarViewHotlist            0x00007 /* View the hotlist                                    */
#define ButtonBarViewResources          0x00008 /* View the resource list                              */
#define ButtonBarLoadImages             0x00009 /* Load images (if they weren't loaded automatically)  */
#define ButtonBarViewSource             0x0000a /* View the page source                                */
#define ButtonBarSaveSource             0x0000b /* Save ancestor document source                       */
#define ButtonBarPrint                  0x0000c /* Print the selected frame contents                   */
#define ButtonBarGoTo                   0x0000d /* Go To button (allows entry of a URL)                */
#define ButtonBarGo                     0x0000e /* Go (companion to above, jumps to URL)               */
#define ButtonBarCancel                 0x0000f /* Cancel a current action                             */
#define ButtonBarSaveAsText             0x00012 /* Save page as plain text                             */
#define ButtonBarSaveAsDraw             0x00013 /* Save page as a Draw file                            */

#define ButtonBarBistate                0x00010 /* The working gadget of a bistate group of 3 gadgets  */
#define ButtonBarTristate               0x00011 /* The working gadget of a tristate group of 4 gadgets */

#define ButtonBarSpacer                 0x00100 /* Invisible gadget to mark height of bar              */
#define ButtonBarBackground             0x00101 /* Background sprite gadget behind button bar          */

/* Button bar event codes (keep in sync with any associated */
/* component IDs - that way things are easier to remember). */

#define EButtonBarHome                  0x00001
#define EButtonBarBack                  0x00002
#define EButtonBarReload                0x00003
#define EButtonBarStop                  0x00004
#define EButtonBarForward               0x00005
#define EButtonBarAddToHotlist          0x00006
#define EButtonBarViewHotlist           0x00007
#define EButtonBarViewResources         0x00008
#define EButtonBarLoadImages            0x00009
#define EButtonBarViewSource            0x0000a
#define EButtonBarSaveSource            0x0000b
#define EButtonBarPrint                 0x0000c
#define EButtonBarGoTo                  0x0000d
#define EButtonBarGo                    0x0000e
#define EButtonBarCancel                0x0000f
#define EButtonBarSaveAsText            0x00012
#define EButtonBarSaveAsDraw            0x00013

#define EButtonBarBistate               0x00010
#define EButtonBarTristate              0x00011

/* URL bar component IDs */

#define URLBarWrit                      0x00200 /* Writable gadget in the URL bar             */
#define URLBarLabel                     0x00201 /* Label on writable gadget in URL bar        */
#define URLBarHistoryMenuR              0x00202 /* History menu button (open to the right)    */
#define URLBarHistoryMenuL              0x00203 /* History menu button (open to the left)     */
#define URLBarDiallerStatus             0x00204 /* Dialler status display                     */
#define URLBarDiallerStatusLabel        0x00205 /* Dialler status label button                */
#define URLBarDiallerStatusCover        0x00206 /* Gadget covering the dialler status display */

#define URLBarSpacer                    0x00300 /* Invisible gadget to mark height of bar     */
#define URLBarBackground                0x00301 /* Background sprite gadget behind URL bar    */

/* URL bar event codes */

#define EURLBarToggleHistory            0x00201 /* Acts as if the history menu popup was clicked on; checks to see if */
                                                /* the MenuR gadget is there, then the MenuL, defaults to MenuR. Will */
                                                /* close the menu if it is already open.                              */
#define EURLBarClearURL                 0x003ff /* Clear the URL writable - as with Ctrl+U (must have input focus).   */

/* Status bar component IDs (there are no event codes) */

#define StatusBarAnimBase               0x00400 /* Static component of status bar animation   */
#define StatusBarAnimAnim               0x00401 /* Animated component of status bar animation */
#define StatusBarStatus                 0x00402 /* Main status line                           */
#define StatusBarStatusCover            0x00403 /* Gadget covering the status line            */
#define StatusBarStatusLabel            0x00404 /* Main status line label                     */
#define StatusBarProgress               0x00405 /* Fetch progress display                     */
#define StatusBarProgressCover          0x00406 /* Gadget covering the progress display       */

#define StatusBarSpacer                 0x00500 /* Invisible gadget to mark height of bar     */

/* 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_Connected,   /* Have just connected to server        */
  Toolbars_Status_SentReq,     /* Have sent request to server          */
  Toolbars_Status_Responded,   /* Server's initial response received   */
  Toolbars_Status_Redirected,  /* Browser redirected to new location   */
  Toolbars_Status_Connecting,  /* Trying to connect to a server        */
  Toolbars_Status_PlugIn,      /* Showing a Plug-In message            */
  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);
_kernel_oserror * toolbars_cancel_all             (browser_data * b);
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);