home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / BookmarkBase.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  8.5 KB  |  267 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /*---------------------------------------*/
  19. /*                                                                        */
  20. /* Name:        BookmarkBase.h                                            */
  21. /* Description:    XFE_BookmarkBase class header.                            */
  22. /*                Base class for components dealing with bookmarks.        */
  23. /* Author:        Ramiro Estrugo <ramiro@netscape.com>                    */
  24. /* Date:        Tue Mar  4 03:45:16 PST 1997                            */
  25.  
  26.  
  27. /*                                                                        */
  28. /*----------------------------------------------------------------------*/
  29.  
  30. #include "NotificationCenter.h"
  31. #include "Frame.h"
  32. #include "intl_csi.h"
  33. #include "bkmks.h"
  34.  
  35. #ifndef _xfe_bookmark_base_h_
  36. #define _xfe_bookmark_base_h_
  37.  
  38. // This class can be used with a DYNA_CASCADEBUTTON or
  39. // DYNA_MENUITEMS.
  40.  
  41. class XFE_BookmarkBase : public XFE_NotificationCenter
  42. {
  43.  
  44. public:
  45.  
  46.      XFE_BookmarkBase            (MWContext *    bookmarkContext,
  47.                                  XFE_Frame *    frame,
  48.                                   XP_Bool        onlyHeaders,
  49.                                  XP_Bool        fancyItems);
  50.  
  51.     virtual ~XFE_BookmarkBase    ();
  52.  
  53.     MWContext *            getBookmarkContext();
  54.  
  55.     static BM_Entry * BM_FindFolderByName    (BM_Entry *        root_entry,
  56.                                              char *            folder_name);
  57.  
  58.     static BM_Entry * BM_FindEntryByAddress(BM_Entry *        root_entry,
  59.                                          const char *    entry_name);
  60.  
  61.     static BM_Entry * BM_FindNextEntry        (BM_Entry *        entry);
  62.     static BM_Entry * BM_FindPreviousEntry    (BM_Entry *        entry);
  63.  
  64.     static XP_Bool    BM_EntryHasHeaderChildren    (BM_Entry *        header);
  65.  
  66.     static void        guessTitle            (XFE_Frame *    frame,
  67.                                          MWContext *    bookmarkContext,
  68.                                          const char *    address,
  69.                                          XP_Bool        sameShell,
  70.                                          char **        resolvedTitleOut,
  71.                                          BM_Date *        resolvedLastDateOut);
  72.     
  73.  
  74.     void            addEntryAfter        (const char *    address,
  75.                                          const char *    title,
  76.                                          BM_Date        lastAccess,
  77.                                          BM_Entry *        entryAfter);
  78.     
  79.     void            addEntryBefore        (const char *    address,
  80.                                          const char *    title,
  81.                                          BM_Date        lastAccess,
  82.                                          BM_Entry *        entryBefore);
  83.     
  84.     void            addEntryToFolder    (const char *    address,
  85.                                          const char *    title,
  86.                                          BM_Date        lastAccess,
  87.                                          BM_Entry *        header);
  88.  
  89.     void            setDropAddress        (const char *    address);
  90.     void            setDropTitle        (const char *    title);
  91.     void            setDropLastAccess    (BM_Date        lastAccess);
  92.  
  93.     const char *    getDropAddress        ();
  94.     const char *    getDropTitle        ();
  95.     BM_Date            getDropLastAccess    ();
  96.  
  97.     // Access methods
  98.     XFE_Frame *        getFrame            ();
  99.  
  100.     virtual void    enableDropping            ();
  101.     virtual void    disableDropping            ();
  102.     virtual XP_Bool    isDroppingEnabled        ();
  103.  
  104. protected:
  105.  
  106.     static Pixmap _bookmarkPixmap;
  107.     static Pixmap _bookmarkMask;
  108.  
  109.     static Pixmap _bookmarkChangedPixmap;
  110.     static Pixmap _bookmarkChangedMask;
  111.  
  112.     static Pixmap _mailBookmarkPixmap;
  113.     static Pixmap _mailBookmarkMask;
  114.  
  115.     static Pixmap _newsBookmarkPixmap;
  116.     static Pixmap _newsBookmarkMask;
  117.  
  118.     static Pixmap _folderArmedPixmap;
  119.     static Pixmap _folderArmedMask;
  120.     static Pixmap _folderPixmap;
  121.     static Pixmap _folderMask;
  122.  
  123.     static Pixmap _personalFolderArmedMask;
  124.     static Pixmap _personalFolderArmedPixmap;
  125.     static Pixmap _personalFolderMask;
  126.     static Pixmap _personalFolderPixmap;
  127.  
  128.     static Pixmap _newFolderArmedMask;
  129.     static Pixmap _newFolderArmedPixmap;
  130.     static Pixmap _newFolderMask;
  131.     static Pixmap _newFolderPixmap;
  132.  
  133.     static Pixmap _menuFolderArmedMask;
  134.     static Pixmap _menuFolderArmedPixmap;
  135.     static Pixmap _menuFolderMask;
  136.     static Pixmap _menuFolderPixmap;
  137.  
  138.     static Pixmap _newMenuFolderArmedMask;
  139.     static Pixmap _newMenuFolderArmedPixmap;
  140.     static Pixmap _newMenuFolderMask;
  141.     static Pixmap _newMenuFolderPixmap;
  142.  
  143.     static Pixmap _newPersonalFolderArmedMask;
  144.     static Pixmap _newPersonalFolderArmedPixmap;
  145.     static Pixmap _newPersonalFolderMask;
  146.     static Pixmap _newPersonalFolderPixmap;
  147.  
  148.     static Pixmap _newPersonalMenuFolderArmedMask;
  149.     static Pixmap _newPersonalMenuFolderArmedPixmap;
  150.     static Pixmap _newPersonalMenuFolderMask;
  151.     static Pixmap _newPersonalMenuFolderPixmap;
  152.  
  153.  
  154.     void getPixmapsForEntry(BM_Entry *    entry,
  155.                             Pixmap *    pixmap,
  156.                             Pixmap *    mask,
  157.                             Pixmap *    armedPixmap,
  158.                             Pixmap *    armedMask);
  159.  
  160. #if 0
  161.     /*     static */ Pixmap bookmarkPixmapFromEntry(BM_Entry *entry);
  162.      /* static */ Pixmap bookmarkMaskFromEntry(BM_Entry *entry);
  163. #endif
  164.  
  165.     // Access bookmark entries
  166.     BM_Entry *        getFirstEntry            ();
  167.     BM_Entry *        getTopLevelFolder        (const char * name);
  168.  
  169.     // Create a bookmark item menu tree
  170.     void            createItemTree            (Widget menu,BM_Entry * entry);
  171.  
  172.     // Install submenu pane that controls dropping disability
  173.     void            trackSubmenuMapping        (Widget submenu);
  174.  
  175.     // Override in derived class to configure
  176.     virtual void    entryArmed                (Widget,BM_Entry *);
  177.     virtual void    entryDisarmed            (Widget,BM_Entry *);
  178.     virtual void    entryActivated            (Widget,BM_Entry *);
  179.     virtual void    entryCascading            (Widget,BM_Entry *);
  180.     virtual void    entryEnter                (Widget,BM_Entry *);
  181.     virtual void    entryLeave                (Widget,BM_Entry *);
  182.  
  183.     // Gets called when the whole thing needs updating
  184.     virtual void    prepareToUpdateRoot        ();
  185.  
  186.     // Gets called to actually update the whole thing
  187.     virtual void    reallyUpdateRoot        ();
  188.  
  189.     // Gets called to update icon appearance
  190.     virtual void    updateAppearance        ();
  191.  
  192.     // Gets called when the personal toolbar folder's name changes
  193.     virtual void    updateToolbarFolderName    ();
  194.  
  195.     // Configure the items
  196.     virtual void    configureXfeCascade        (Widget,BM_Entry *);
  197.     virtual void    configureXfeButton        (Widget,BM_Entry *);
  198.     virtual void    configureXfeBmButton    (Widget,BM_Entry *);
  199.     virtual void    configureXfeBmCascade    (Widget,BM_Entry *);
  200.     virtual void    configureButton            (Widget,BM_Entry *);
  201.     virtual void    configureCascade        (Widget,BM_Entry *);
  202.     virtual void    configureSeparator        (Widget,BM_Entry *);
  203.  
  204.     // Menu component creation methods
  205.     Widget    createCascadeButton        (Widget menu,BM_Entry * entry,XP_Bool ignore_children);
  206.     Widget    createPushButton        (Widget menu,BM_Entry * entry);
  207.     Widget    createSeparator            (Widget menu);
  208.     Widget    createMoreButton        (Widget menu);
  209.  
  210.     // Toolbar component creation methods
  211.     Widget    createXfeCascade        (Widget parent,BM_Entry * entry);
  212.     Widget    createXfeButton            (Widget parent,BM_Entry * entry);
  213.  
  214.     BM_Entry * getRootFolder        ();
  215.     BM_Entry * getAddFolder            ();
  216.     BM_Entry * getMenuFolder        ();
  217.  
  218. private:
  219.  
  220.     MWContext *            _bookmarkContext;        // Bookmark context
  221.     XFE_Frame *            _frame;                    // The ancestor frame
  222.     XP_Bool                _onlyHeaders;            // Only show headers
  223.     XP_Bool                _fancyItems;            // Fancy items (pixmap & label)
  224.     INTL_CharSetInfo    _charSetInfo;            // Char set info
  225.  
  226.     char *                _dropAddressBuffer;        // 
  227.     char *                _dropTitleBuffer;        // 
  228.     BM_Date                _dropLastAccess;        // 
  229.  
  230.     // Item callbacks
  231.     static void        item_armed_cb        (Widget,XtPointer,XtPointer);
  232.     static void        item_disarmed_cb    (Widget,XtPointer,XtPointer);
  233.      static void        item_activated_cb    (Widget,XtPointer,XtPointer);
  234.      static void        item_cascading_cb    (Widget,XtPointer,XtPointer);
  235.      static void        item_enter_cb        (Widget,XtPointer,XtPointer);
  236.      static void        item_leave_cb        (Widget,XtPointer,XtPointer);
  237.      static void        item_free_data_cb    (Widget,XtPointer,XtPointer);
  238.     static void        pane_mapping_eh        (Widget,XtPointer,XEvent *,Boolean *);
  239.  
  240.     // Format item blah blah blah
  241.     static XmString    formatItem            (MWContext *    bookmarkContext, 
  242.                                          BM_Entry *        entry, 
  243.                                          Boolean        no_indent,
  244.                                          int16            charset);
  245.  
  246.     // Obtain an internationallized XmString from an entry
  247.     static XmString entryToXmString    (MWContext *        bookmarkContext,
  248.                                      BM_Entry *            entry,
  249.                                      INTL_CharSetInfo    char_set_info);
  250.  
  251.  
  252.     void createPixmaps();
  253.  
  254.     Widget    getLastMoreMenu        (Widget menu);
  255.  
  256.     // Bookmarks changed notice invoked by MozillaApp
  257.     XFE_CALLBACK_DECL(bookmarksChanged)
  258.  
  259.     // update the icon appearance
  260.     XFE_CALLBACK_DECL(updateIconAppearance)
  261.  
  262.     // update the personal toolbar folder
  263.     XFE_CALLBACK_DECL(updatePersonalToolbarFolderName)
  264. };
  265.  
  266. #endif /* _xfe_bookmark_base_h_ */
  267.