home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / BookmarkView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  8.1 KB  |  229 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.    BookmarkView.h -- class definition for BookmarkView
  20.    Created: Chris Toshok <toshok@netscape.com>, 7-Aug-96.
  21.  */
  22.  
  23.  
  24.  
  25. #ifndef _xfe_bookmarkview_h
  26. #define _xfe_bookmarkview_h
  27.  
  28. #include "View.h"
  29. #include "Outliner.h"
  30. #include "Outlinable.h"
  31. #include "PopupMenu.h"
  32. #include "BookmarkPropDialog.h"
  33. #include "BookmarkWhatsNewDialog.h"
  34. #include "bkmks.h"
  35.  
  36. typedef struct BookmarkClipboard {
  37.   void *block;
  38.   int32 length;
  39. } BookmarkClipboard;
  40.  
  41. class XFE_BookmarkView : public XFE_View, public XFE_Outlinable
  42. {
  43. public:
  44.   XFE_BookmarkView(XFE_Component *toplevel, Widget parent, XFE_View *parent_view, MWContext *context);
  45.  
  46.   ~XFE_BookmarkView();
  47.  
  48.   // Methods we override from XFE_View
  49.   virtual Boolean isCommandEnabled(CommandType cmd, void *calldata = NULL,
  50.                                    XFE_CommandInfo* i = NULL);
  51.   virtual void doCommand(CommandType cmd, void *calldata = NULL,
  52.                                    XFE_CommandInfo* i = NULL);
  53.   virtual Boolean handlesCommand(CommandType cmd, void *calldata = NULL,
  54.                                    XFE_CommandInfo* i = NULL);
  55.   virtual XP_Bool isCommandSelected(CommandType cmd, void *calldata,
  56.                                     XFE_CommandInfo* info);
  57.   virtual char *commandToString(CommandType cmd, void *calldata = NULL,
  58.                                    XFE_CommandInfo* i = NULL);
  59.   
  60.   // Our equivalent to the BMFE_* calls
  61.   void refreshCells(int first = 1, int last = BM_LAST_CELL,
  62.                     XP_Bool now = TRUE);
  63.   void gotoBookmark(const char *url);
  64.   void scrollIntoView(BM_Entry *entry);
  65.   void setClipContents(void *block, int32 length);
  66.   void *getClipContents(int32 *length);
  67.   void freeClipContents();
  68.   void startWhatsChanged();
  69.   void updateWhatsChanged(const char *url, int32 done, int32 total, const char *totaltime);
  70.   void finishedWhatsChanged(int32 totalchecked, int32 numreached, int32 numchanged);
  71.   void startBatch();
  72.   void endBatch();
  73.   void bookmarkMenuInvalid();
  74.  
  75.   // Wrapper around BM_SetName() that handles personal toolbar folder
  76.   void setName(BM_Entry *entry, char *name);
  77.  
  78.   Boolean loadBookmarks(char *filename);
  79.   Boolean copyBookmarksFile(char *dst, char *src);
  80.  
  81.   // The Outlinable interface.
  82.   virtual void *ConvFromIndex(int index);
  83.   virtual int ConvToIndex(void *item);
  84.  
  85.   virtual char *getColumnName(int column);
  86.  
  87.   virtual char *getColumnHeaderText(int column);
  88.   virtual fe_icon *getColumnHeaderIcon(int column);
  89.   virtual EOutlinerTextStyle getColumnHeaderStyle(int column);
  90.   virtual void *acquireLineData(int line);
  91.   virtual void getTreeInfo(XP_Bool *expandable, XP_Bool *is_expanded, 
  92.                            int *depth, OutlinerAncestorInfo **ancestor);
  93.   virtual EOutlinerTextStyle getColumnStyle(int column);
  94.   virtual char *getColumnText(int column);
  95.   virtual fe_icon *getColumnIcon(int column);
  96.   virtual void releaseLineData();
  97.  
  98.   virtual void Buttonfunc(const OutlineButtonFuncData *data);
  99.   virtual void Flippyfunc(const OutlineFlippyFuncData *data);
  100.  
  101.   virtual XFE_Outliner *getOutliner();
  102.   // Get tooltipString & docString; 
  103.   // returned string shall be freed by the callee
  104.   // row < 0 indicates heading row; otherwise it is a content row
  105.   // (starting from 0)
  106.   //
  107.   virtual char *getCellTipString(int /* row */, int /* column */) {return NULL;}
  108.   virtual char *getCellDocString(int /* row */, int /* column */) {return NULL;}
  109.  
  110.   // columns for the Outliner
  111.   static const int OUTLINER_COLUMN_NAME;
  112.   static const int OUTLINER_COLUMN_LOCATION;
  113.   static const int OUTLINER_COLUMN_LASTVISITED;
  114.   static const int OUTLINER_COLUMN_CREATEDON;
  115.  
  116.   static const char *bookmarksChangedCallback; // the user has added/editted/deleted a bookmark entry.
  117.   static const char *bookmarkDoubleClickedCallback;  // the user has double clicked a bookmark entry.
  118.   static const char *bookmarkClickedCallback; // the user has single clicked a bookmark entry.
  119.  
  120.   // Open properties dialog
  121.   void openBookmarksWindow();
  122.   void closeBookmarksWindow();
  123.  
  124.   // Edit an item in the properties dialog if it's open
  125.   void editItem(BM_Entry *entry);
  126.   void entryGoingAway(BM_Entry *entry);
  127.  
  128.   void makeEditItemDialog();
  129.  
  130. #if defined(USE_MOTIF_DND)
  131.  
  132.   /* motif drag and drop interface. */
  133.   fe_icon_data *GetDragIconData(int row, int column);
  134.   static fe_icon_data *getDragIconData(void *this_ptr,
  135.                                        int row, int column);
  136.  
  137.   void GetDragTargets(int row, int column, Atom **targets, int *num_targets);
  138.   static void getDragTargets(void *this_ptr,
  139.                              int row, int col,
  140.                              Atom **targets, int *num_targets);
  141.  
  142.   char *DragConvert(Atom atom);
  143.   static char* dragConvert(void *this_ptr,
  144.                            Atom atom);
  145.   
  146.   int ProcessTargets(int row, int col,
  147.                      Atom *targets,
  148.                      const char **data,
  149.                      int numItems);
  150.   static int processTargets(void *this_ptr,
  151.                             int row, int col,
  152.                             Atom *targets,
  153.                             const char **data,
  154.                             int numItems);
  155.  
  156.   /* no instance method needed for getDropTargets */
  157.   static void getDropTargets(void *this_ptr,
  158.                              Atom **targets, int *num_targets);
  159. #endif /* USE_MOTIF_DND */
  160.  
  161. private:
  162.   BM_Entry *m_entry;                    // needed by the outlinable interface methods.
  163.   int m_entryDepth;                     // needed by the outlinable interface methods.
  164.   OutlinerAncestorInfo *m_ancestorInfo; // needed by the outlinable interface methods.
  165.  
  166.   XFE_Outliner *m_outliner; // the outliner object used to display everything.
  167.   XFE_PopupMenu *m_popup;
  168.  
  169.   XP_Bool m_sortDescending;
  170.   CommandType m_lastSort;
  171.  
  172.   BookmarkClipboard clip;   // our clipboard.
  173.   BM_Entry *m_editentry;    // the entry currently being editted
  174.   
  175.   XFE_BookmarkPropDialog *m_propertiesDialog;
  176.   XFE_BookmarkWhatsNewDialog *m_whatsNewDialog;
  177.  
  178.   // Use these to avoid multiple FE updates
  179.   XP_Bool m_batchDepth;
  180.   XP_Bool m_menuIsInvalid;
  181.  
  182.   static MenuSpec open_popup_spec[];
  183.   static MenuSpec new_popup_spec[];
  184.   static MenuSpec set_popup_spec[];
  185.   static MenuSpec saveas_popup_spec[];
  186.   static MenuSpec cutcopy_popup_spec[];
  187.   static MenuSpec copylink_popup_spec[];
  188.   static MenuSpec paste_popup_spec[];
  189.   static MenuSpec delete_popup_spec[];
  190.   static MenuSpec makealias_popup_spec[];
  191.   static MenuSpec properties_popup_spec[];
  192.  
  193.   // Remove our reference to the dialog when it goes away
  194.   static void properties_destroy_cb(Widget widget,
  195.                                     XtPointer closure, XtPointer call_data);
  196.   static void whats_new_destroy_cb(Widget widget,
  197.                                     XtPointer closure, XtPointer call_data);
  198.  
  199.   BM_CommandType commandToBMCmd(CommandType cmd);
  200.  
  201. #if !defined(USE_MOTIF_DND)
  202.  
  203.   void dropfunc(Widget dropw, fe_dnd_Event type, fe_dnd_Source *source, XEvent *event);
  204.   static void drop_func(Widget dropw, void *closure, fe_dnd_Event type,
  205.             fe_dnd_Source *source, XEvent* event);
  206. #endif
  207.  
  208.   void doPopup(XEvent *event);
  209.  
  210.   // icons for use in the bookmark window.
  211.   static fe_icon bookmark;
  212.   static fe_icon mailBookmark;
  213.   static fe_icon newsBookmark;
  214.   static fe_icon changedBookmark;
  215.   //  static fe_icon unknownBookmark;
  216.   static fe_icon closedFolder;
  217.   static fe_icon openedFolder;
  218.   static fe_icon closedPersonalFolder;
  219.   static fe_icon openedPersonalFolder;
  220.   static fe_icon closedFolderDest;
  221.   static fe_icon openedFolderDest;
  222.   static fe_icon closedFolderMenu;
  223.   static fe_icon openedFolderMenu;
  224.   static fe_icon closedFolderMenuDest;
  225.   static fe_icon openedFolderMenuDest;
  226. };
  227.  
  228. #endif /* _xfe_bookmarkview_h */
  229.