/* 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   : Hotlist.h                              */
/*                                                 */
/* Purpose: Managing a hotlist in the browser.     */
/*                                                 */
/* Author : D.T.A.Brown                            */
/*                                                 */
/* History: 06-Aug-97: Created.                    */
/*          22-Aug-97: (ADH/DTAB) Integrated into  */
/*                     main browser code.          */
/*          25-Aug-97: (ADH) Definitions imported  */
/*                     from TBEvents.h.            */
/***************************************************/

#ifndef REMOTE_HOTLIST

  /* Hotlist dialogue event codes. Reuse of the same dialogue for  */
  /* different actions (e.g. New and Edit URL) make these a little */
  /* unusual.                                                      */

  #define EHotlistShowNewURL               0x025ff
  #define EHotlistShowEditURL              0x025fe
  #define EHotlistShowNewDirectory         0x025fd
  #define EHotlistShowRenameDirectory      0x025fc

  #define EHotlistNewEditURLOK             0x025fb
  #define EHotlistNewEditURLCancel         0x025fa
  #define EHotlistNewRenameDirectoryOK     0x025f9
  #define EHotlistNewRenameDirectoryCancel 0x025f8

  /* Enumerations */

  typedef enum hotlist_type
  {
    hl_directory,
    hl_url,

    /* Special case to allow range checking - must be the last item */

    hl_ALL

  } hotlist_type;

  /* Structures */

  typedef struct hotlist_item
  {
    hotlist_type             type;              /* Item type */
    unsigned int             flags;
    char                   * name;              /* Leaf name (NULL terminated string) */

    union
    {
      char                 * url;               /* Pointer to url (NULL terminated string) */
      struct hotlist_item  * directory_content; /* Pointer to directory contents */
      void                 * generic_data;      /* generic type */

    } data;

    struct hotlist_item    * parent;            /* Points to parent directory or NULL if none      */
    struct hotlist_item    * previous;          /* Points to previous hotlist_item or NULL if none */
    struct hotlist_item    * next;              /* Points to next hotlist_item or NULL if no more  */

  } hotlist_item;

  /* Miscellaneous definitions */

  #define HOTLIST_MAX_TYPE                    hl_url

  #define HOTLIST_G_IS_SELECTED               (1<<0)
  #define HOTLIST_G_REDRAW_NOW                (1<<1)
  #define HOTLIST_G_DRAG_SELECTED             (1<<2)

  #define HOTLIST_D_IS_OPEN                   (1<<16)
  #define HOTLIST_D_IS_HIGHLIGHTED            (1<<17)

  #define DIRECTORY_FLAGS                     HOTLIST_G_REDRAW_NOW

  #define URL_FLAGS                           HOTLIST_G_REDRAW_NOW

  #define HOTLIST_SPRITE_ICON_FLAGS           (WimpIcon_Sprite       |   \
                                               WimpIcon_HCentred     |   \
                                               WimpIcon_VCentred     |   \
                                               WimpIcon_Indirected   |   \
                                               WimpIcon_FGColour * 7 |   \
                                               WimpIcon_BGColour * 0)

  #define HOTLIST_TEXT_ICON_FLAGS_SELECTED    (WimpIcon_Text         |   \
                                               WimpIcon_Filled       |   \
                                               WimpIcon_VCentred     |   \
                                               WimpIcon_Indirected   |   \
                                               WimpIcon_FGColour * 1 |   \
                                               WimpIcon_BGColour * 7)

  #define HOTLIST_TEXT_ICON_FLAGS_UNSELECTED  (WimpIcon_Text         |   \
                                               WimpIcon_VCentred     |   \
                                               WimpIcon_Indirected   |   \
                                               WimpIcon_FGColour * 7 |   \
                                               WimpIcon_BGColour * 0)

  #define HOTLIST_TEXT_ICON_FLAGS_DRAG        (WimpIcon_Text         |   \
                                               WimpIcon_Filled       |   \
                                               WimpIcon_VCentred     |   \
                                               WimpIcon_Indirected   |   \
                                               WimpIcon_FGColour * 7 |   \
                                               WimpIcon_BGColour * 1)

  #define HOTLIST_POSITION_BEFORE             0 /* before item */
  #define HOTLIST_POSITION_AFTER              1 /* after item  */
  #define HOTLIST_POSITION_BEGINNING          2 /* beginning of directory */
  #define HOTLIST_POSITION_END                3 /* end of directory */

  #define HOTLIST_NOT_DRAGGING                0
  #define HOTLIST_BOX_DRAG                    1
  #define HOTLIST_SOLID_DRAG_OBJECT           2
  #define HOTLIST_SOLID_DRAG_SPRITE           3
  #define HOTLIST_BOX_DRAG_SELECTION          4

  #define HOTLIST_WINDOW_MIN_WIDTH            480
  #define HOTLIST_WINDOW_MIN_HEIGHT           3       /* In items */

  #define HOTLIST_MENUSECTION_NEW             1
  #define HOTLIST_MENUSECTION_ALTER           2

  #define OPEN_DIRECTORY_SPRITE               "small_diro"
  #define CLOSED_DIRECTORY_SPRITE             "small_dir"
  #define INSERT_DIRECTORY_SPRITE             "small_dir+"
  #define URL_SPRITE                          "small_f91"
  #define SELECTION_SPRITE                    "package"

  #define HL_MODIFIED_ADD                     0
  #define HL_MODIFIED_DELETE                  1
  #define HL_MODIFIED_MOVE                    2
  #define HL_MODIFIED_COPY                    3
  #define HL_MODIFIED_LOAD                    4
  #define HL_MODIFIED_ALTER                   5

  #define HL_SAVE_NONE                        0
  #define HL_SAVE_URI                         1
  #define HL_SAVE_HTML                        2

  /* Various component IDs */

  #define HOTLIST_URL_MENUITEM                0x05
  #define HOTLIST_SELECTALL_MENUITEM          0x00
  #define HOTLIST_CLEARSELECTION_MENUITEM     0x01
  #define HOTLIST_NEWDIRECTORY_MENUITEM       0x02
  #define HOTLIST_NEWURL_MENUITEM             0x06
  #define HOTLIST_OPENALL_MENUITEM            0x03
  #define HOTLIST_CLOSEALL_MENUITEM           0x04
  #define HOTLIST_DISPLAY_MENUITEM            0x07

  #define HOTLIST_MENU_SHOWDESCRIPTIONS       0x00
  #define HOTLIST_MENU_SHOWURLS               0x01

  /* (Use MiscHotlistSaveObject for all of the submenu 'save' items) */

  #define HOTLIST_RENAME_SUBMENUITEM          0x01
  #define HOTLIST_DELETE_SUBMENUITEM          0x02

  #define HOTLIST_NEWDIRECTORY_NAME           0x01
  #define HOTLIST_NEWDIRECTORY_CANCEL         0x03
  #define HOTLIST_NEWDIRECTORY_NEW            0x02

  #define HOTLIST_NEWURL_NAME                 0x01
  #define HOTLIST_NEWURL_URL                  0x05
  #define HOTLIST_NEWURL_CANCEL               0x03
  #define HOTLIST_NEWURL_NEW                  0x02

  /* Function prototypes */

  _kernel_oserror * hotlist_initialise           (void);

  _kernel_oserror * hotlist_open                 (int show_type, void * type, int show_urls);
  _kernel_oserror * hotlist_close                (void);
  ObjectId          hotlist_return_window_id     (void);

  _kernel_oserror * hotlist_load                 (char * filename);
  _kernel_oserror * hotlist_add_html_file        (int x, int y, char * path);
  _kernel_oserror * hotlist_save_hotlist         (char * filename, int type);
  _kernel_oserror * hotlist_save                 (char * filename);

  hotlist_item    * hotlist_find_selected_item   (void);
  unsigned int      hotlist_count_selected_items (void);

  _kernel_oserror * hotlist_add                  (char * description, char * url, int at_bottom);
  _kernel_oserror * hotlist_add_position         (int x, int y, char * description, char * url);

  _kernel_oserror * hotlist_clear_selection      (void);

  int               hotlist_find_match           (char * buffer, int buffer_size);

#endif