home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / HistoryFrame.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  5.9 KB  |  185 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.    HistoryFrame.cpp -- History window stuff
  20.    Created: Stephen Lamm <slamm@netscape.com>, 24-Feb-96.
  21.  */
  22.  
  23.  
  24.  
  25. #include "HistoryFrame.h"
  26. #include "HistoryView.h"
  27. #include "xpassert.h"
  28. #include "xfe2_extern.h"
  29. #include "abdefn.h"                // for kMaxFullNameLength
  30. #include "xpgetstr.h"            // for XP_GetString()
  31. #include "Dashboard.h"
  32.  
  33. extern int XFE_HISTORY_FRAME_TITLE;
  34.  
  35. static XFE_HistoryFrame *theFrame = NULL;
  36.  
  37. // Basically, anything with "" around it hasn't been wired-up/implemented.
  38. MenuSpec XFE_HistoryFrame::file_menu_spec[] = {
  39.   { "newSubmenu",           CASCADEBUTTON,
  40.     (MenuSpec*)&XFE_Frame::new_menu_spec },
  41.   MENU_SEPARATOR,
  42.   { xfeCmdSaveAs,           PUSHBUTTON },
  43.   MENU_SEPARATOR,
  44.   { xfeCmdOpenSelected,     PUSHBUTTON },
  45.   { xfeCmdAddBookmark,      PUSHBUTTON },
  46.   { xfeCmdAddToToolbar,     PUSHBUTTON },
  47.   //{ xfeCmdCreateShortcut,   PUSHBUTTON },  // Create desktop shortcut
  48.   //MENU_SEPARATOR,
  49.   //{ xfeCmdPrintSetup,        PUSHBUTTON },
  50.   //{ xfeCmdPrint,            PUSHBUTTON },
  51.   MENU_SEPARATOR,
  52.   { xfeCmdClose,            PUSHBUTTON },  
  53.   { xfeCmdExit,             PUSHBUTTON },
  54.   { NULL }
  55. };
  56.  
  57. MenuSpec XFE_HistoryFrame::edit_menu_spec[] = {
  58.   { xfeCmdUndo,        PUSHBUTTON },
  59.   { xfeCmdRedo,        PUSHBUTTON },
  60.   MENU_SEPARATOR,
  61.   { xfeCmdCut,        PUSHBUTTON },
  62.   { xfeCmdCopy,        PUSHBUTTON },
  63.   { xfeCmdDelete,    PUSHBUTTON },
  64.   { xfeCmdSelectAll,    PUSHBUTTON },
  65.   MENU_SEPARATOR,
  66.   //{ xfeCmdSearch,    PUSHBUTTON },  // We should have this, but it isn't ready
  67. #ifdef MOZ_MAIL_NEWS
  68.   { xfeCmdSearchAddress,    PUSHBUTTON },
  69.   MENU_SEPARATOR,
  70. #endif
  71.   { xfeCmdEditPreferences,    PUSHBUTTON },
  72.   { NULL }
  73. };
  74.  
  75. MenuSpec XFE_HistoryFrame::view_menu_spec[] = {
  76.   { xfeCmdSortByTitle, TOGGLEBUTTON, NULL, "sortByRadioGroup",
  77.     False, (void*)eHSC_TITLE },
  78.   { xfeCmdSortByLocation, TOGGLEBUTTON, NULL, "sortByRadioGroup", 
  79.     False, (void*)eHSC_LOCATION },
  80.   { xfeCmdSortByDateFirstVisited, TOGGLEBUTTON, NULL, "sortByRadioGroup",
  81.     False, (void*)eHSC_FIRSTVISIT },
  82.   { xfeCmdSortByDateLastVisited, TOGGLEBUTTON, NULL, "sortByRadioGroup",
  83.     False, (void*)eHSC_LASTVISIT },
  84.   { xfeCmdSortByExpirationDate, TOGGLEBUTTON, NULL, "sortByRadioGroup", 
  85.     False, (void*)eHSC_EXPIRES },
  86.   { xfeCmdSortByVisitCount, TOGGLEBUTTON, NULL, "sortByRadioGroup", 
  87.     False, (void*)eHSC_VISITCOUNT },
  88.   MENU_SEPARATOR,
  89.   { xfeCmdSortAscending, TOGGLEBUTTON, NULL, "ascendDescendRadioGroup", 
  90.     False },
  91.   { xfeCmdSortDescending, TOGGLEBUTTON, NULL, "ascendDescendRadioGroup", 
  92.     False },
  93.   //MENU_SEPARATOR,
  94.   //{ xfeCmdMoreOptions,  PUSHBUTTON },
  95.   //{ xfeCmdFewerOptions, PUSHBUTTON },
  96.   { NULL }
  97. };
  98.  
  99. MenuSpec XFE_HistoryFrame::menu_bar_spec[] = {
  100.   { xfeMenuFile,    CASCADEBUTTON, file_menu_spec },
  101.   { xfeMenuEdit,    CASCADEBUTTON, edit_menu_spec },
  102.   { xfeMenuView,    CASCADEBUTTON, view_menu_spec },
  103.   { xfeMenuWindow,    CASCADEBUTTON, XFE_Frame::window_menu_spec },
  104.   { xfeMenuHelp,     CASCADEBUTTON, XFE_Frame::help_menu_spec },
  105.   { NULL }
  106. };
  107. //////////////////////////////////////////////////////////////////////////
  108. XFE_HistoryFrame::XFE_HistoryFrame(Widget toplevel, XFE_Frame *parent_frame, Chrome *chromespec) 
  109.   : XFE_Frame("history", toplevel, parent_frame,
  110.           FRAME_HISTORY, chromespec, False, True, False, True, False)
  111. {
  112.   // create the History view
  113.   XFE_HistoryView *view = new XFE_HistoryView(this, getViewParent(), NULL, m_context);
  114.   setView(view);
  115.  
  116.   XtVaSetValues(view->getBaseWidget(),
  117.           XmNleftAttachment, XmATTACH_FORM,
  118.         XmNtopAttachment, XmATTACH_FORM,
  119.         XmNrightAttachment, XmATTACH_FORM,
  120.         XmNbottomAttachment, XmATTACH_FORM,
  121.         NULL);
  122.  
  123.   setMenubar(menu_bar_spec);
  124.  
  125.   //
  126.   // Make the bookmark frame title more reasonable
  127.   //
  128.   char title[kMaxFullNameLength+64];
  129.  
  130.   PR_snprintf(title, 
  131.               sizeof(title),
  132.               XP_GetString(XFE_HISTORY_FRAME_TITLE),
  133.               FE_UsersFullName());
  134.  
  135.   setTitle(title);
  136.  
  137.   view->show();
  138.  
  139.   m_dashboard->setShowStatusBar(True);
  140.   m_dashboard->setShowProgressBar(True);
  141. }
  142. //////////////////////////////////////////////////////////////////////////
  143. XFE_HistoryFrame::~XFE_HistoryFrame()
  144. {
  145. }
  146. //////////////////////////////////////////////////////////////////////////
  147. void
  148. XFE_HistoryFrame::showHistory(Widget toplevel, XFE_Frame *parent_frame, Chrome *chromespec)
  149. {
  150.     fe_showHistory(toplevel, parent_frame, chromespec);
  151. }
  152. //////////////////////////////////////////////////////////////////////////
  153. XP_Bool
  154. XFE_HistoryFrame::isCommandEnabled(CommandType cmd,
  155.                                    void *calldata, XFE_CommandInfo*)
  156. {
  157.   if (cmd == xfeCmdClose)
  158.     return True;
  159.   else
  160.     return XFE_Frame::isCommandEnabled(cmd, calldata);
  161. }
  162.  
  163. extern "C" MWContext*
  164. fe_showHistory(Widget toplevel, XFE_Frame *parent_frame, Chrome *chromespec)
  165. {
  166.   /* Check to see if we have access to the global history database. */
  167.   if (fe_globalData.all_databases_locked)
  168.     return NULL;
  169.  
  170.   fe_createHistory(toplevel, parent_frame, chromespec);
  171.  
  172.   theFrame->show();
  173.  
  174.   return theFrame->getContext();
  175. }
  176.  
  177. extern "C" void
  178. fe_createHistory(Widget toplevel,
  179.                  XFE_Frame *parent_frame,
  180.                  Chrome *chromespec)
  181. {
  182.   if (theFrame == NULL)
  183.     theFrame = new XFE_HistoryFrame(toplevel, parent_frame, chromespec);
  184. }
  185.