home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / HistoryView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.1 KB  |  190 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.    HistoryView.h -- class definition for HistoryView
  20.    Created: Stephen Lamm <slamm@netscape.com>, 24-Feb-96.
  21.  */
  22.  
  23.  
  24.  
  25. #ifndef _xfe_historyview_h
  26. #define _xfe_historyview_h
  27.  
  28. #include "View.h"
  29. #include "Outliner.h"
  30. #include "Outlinable.h"
  31.  
  32. #include "glhist.h"
  33. #include "xp.h"
  34.  
  35. enum enHistSortCol
  36. {
  37.    eHSC_INVALID = -1,
  38.    eHSC_TITLE,
  39.    eHSC_LOCATION,
  40.    eHSC_FIRSTVISIT,
  41.    eHSC_LASTVISIT,
  42.    eHSC_EXPIRES,
  43.    eHSC_VISITCOUNT
  44. };
  45.  
  46. typedef struct HistoryClipboard {
  47.   void *block;
  48.   int32 length;
  49. } HistoryClipboard;
  50.  
  51. class XFE_HistoryView : public XFE_View, public XFE_Outlinable
  52. {
  53. public:
  54.   XFE_HistoryView(XFE_Component *toplevel, Widget parent, XFE_View *parent_view, MWContext *context);
  55.  
  56.   ~XFE_HistoryView();
  57.  
  58.   // Methods we override from XFE_View
  59.   virtual Boolean isCommandEnabled(CommandType cmd, void *calldata = NULL,
  60.                                    XFE_CommandInfo* i = NULL);
  61.   virtual void doCommand(CommandType cmd, void *calldata = NULL,
  62.                                    XFE_CommandInfo* i = NULL);
  63.   virtual Boolean handlesCommand(CommandType cmd, void *calldata = NULL,
  64.                                    XFE_CommandInfo* i = NULL);
  65.   virtual char *commandToString(CommandType cmd, void *calldata = NULL,
  66.                                    XFE_CommandInfo* i = NULL);
  67.   virtual XP_Bool isCommandSelected(CommandType cmd,
  68.                                     void *calldata = NULL,
  69.                                     XFE_CommandInfo* info = NULL);
  70.   
  71.   // Our equivalent to the backend calls
  72.   void refreshCells(int first, int last, XP_Bool now);
  73.   void scrollIntoView(gh_HistEntry *entry);
  74.   void setClipContents(void *block, int32 length);
  75.   void *getClipContents(int32 *length);
  76.   void freeClipContents();
  77.   //  void openHistoryWindow();
  78.  
  79.   // public access to history list
  80.   virtual gh_HistEntry *getEntry(int);
  81.  
  82.   //Boolean loadHistory(char *filename);
  83.  
  84.   // The Outlinable interface.
  85.   virtual void *ConvFromIndex(int index);
  86.   virtual int ConvToIndex(void *item);
  87.  
  88.   virtual char *getColumnName(int column);
  89.  
  90.   virtual char *getColumnHeaderText(int column);
  91.   virtual fe_icon *getColumnHeaderIcon(int column);
  92.   virtual EOutlinerTextStyle getColumnHeaderStyle(int column);
  93.   virtual void *acquireLineData(int line);
  94.   virtual void getTreeInfo(XP_Bool *expandable, XP_Bool *is_expanded, 
  95.                            int *depth, OutlinerAncestorInfo **ancestor);
  96.   virtual EOutlinerTextStyle getColumnStyle(int column);
  97.   virtual char *getColumnText(int column);
  98.   virtual fe_icon *getColumnIcon(int column);
  99.   virtual void releaseLineData();
  100.  
  101.   virtual void Buttonfunc(const OutlineButtonFuncData *data);
  102.   virtual void Flippyfunc(const OutlineFlippyFuncData *data);
  103.  
  104.   virtual XFE_Outliner *getOutliner();
  105.   // Get tooltipString & docString; 
  106.   // returned string shall be freed by the callee
  107.   // row < 0 indicates heading row; otherwise it is a content row
  108.   // (starting from 0)
  109.   //
  110.   virtual char *getCellTipString(int /* row */, int /* column */) {return NULL;}
  111.   virtual char *getCellDocString(int /* row */, int /* column */) {return NULL;}
  112.  
  113.   // columns for the Outliner
  114.   static const int OUTLINER_COLUMN_TITLE;
  115.   static const int OUTLINER_COLUMN_LOCATION;
  116.   static const int OUTLINER_COLUMN_FIRSTVISITED;
  117.   static const int OUTLINER_COLUMN_LASTVISITED;
  118.   static const int OUTLINER_COLUMN_EXPIRES;
  119.   static const int OUTLINER_COLUMN_VISITCOUNT;
  120.  
  121. #if defined(USE_MOTIF_DND)
  122.  
  123.   /* motif drag and drop interface. */
  124.   fe_icon_data *GetDragIconData(int row, int column);
  125.   static fe_icon_data *getDragIconData(void *this_ptr,
  126.                                        int row, int column);
  127.  
  128.   void GetDragTargets(int row, int column, Atom **targets, int *num_targets);
  129.   static void getDragTargets(void *this_ptr,
  130.                              int row, int col,
  131.                              Atom **targets, int *num_targets);
  132.  
  133.   char *DragConvert(Atom atom);
  134.   static char* dragConvert(void *this_ptr,
  135.                            Atom atom);
  136. #endif /* USE_MOTIF_DND */
  137.  
  138.   static const char *historysChangedCallback; // the user has added/editted/deleted a history entry.
  139.   static const char *historyDoubleClickedCallback;  // the user has double clicked a history entry.
  140.   static const char *historyClickedCallback; // the user has single clicked a history entry.
  141.  
  142. private:
  143.   GHHANDLE m_histCursor;
  144.   int m_totalLines;
  145.  
  146.   XP_Bool m_dirty;
  147.  
  148.   enHistSortCol m_sortBy;
  149.   XP_Bool       m_sortDescending;
  150.   gh_Filter*    m_filter;
  151.  
  152.   // needed by the outlinable interface methods.
  153.   OutlinerAncestorInfo *m_ancestorInfo;
  154.   gh_HistEntry *m_entry;
  155.  
  156. #if defined(USE_MOTIF_DND)
  157.   /* the entry that we're currently dragging. */
  158.   gh_HistEntry *m_dragentry;
  159. #endif /* USE_MOTIF_DND */
  160.  
  161.   XFE_Outliner *m_outliner;
  162.  
  163.   XP_List *m_selectList;
  164.  
  165.   // icons for use in the history window.
  166.   static fe_icon historyIcon;
  167.  
  168.   void dropfunc(Widget dropw, fe_dnd_Event type,
  169.                 fe_dnd_Source *source, XEvent *event);
  170.   static void drop_func(Widget dropw, void *closure, fe_dnd_Event type,
  171.                         fe_dnd_Source *source, XEvent* event);
  172.  
  173.   gh_HistEntry *getSelection();
  174.  
  175.   void openSelected();
  176.   void reflectSelected();
  177.   void saveSelected();
  178.   void restoreSelected();
  179.  
  180.   int notify(gh_NotifyMsg *msg);
  181.   static int notify_cb(gh_NotifyMsg *msg);
  182.  
  183.   void resort(enHistSortCol sortBy, XP_Bool sortDescending);
  184.  
  185.   void refresh();
  186.   static void refresh_cb(XtPointer closure, XtIntervalId *id);
  187. };
  188.  
  189. #endif /* _xfe_historyview_h */
  190.