home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / MNSearchView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  8.0 KB  |  268 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.    MNSearchView.h -- class definitions for mail/news search view.
  20.    Created: Dora Hsu <dora@netscape.com>, 15-Dec-96.
  21.  */
  22.  
  23.  
  24.  
  25. #ifndef _xfe_mnsearchview_h
  26. #define _xfe_mnsearchview_h
  27.  
  28. #include "MNListView.h"
  29. #include "Outliner.h"
  30. #include "Command.h"
  31. #include "msg_srch.h"
  32. #include "Menu.h"       // for struct MenuSpec
  33.  
  34. class XFE_MsgFrame;
  35. class XFE_Dashboard;
  36. class XFE_FolderDropdown;
  37. class XFE_PopupMenu;
  38. class XFE_Button;
  39.  
  40.  
  41.  
  42. typedef 
  43. struct XFE_SearchElement
  44. {
  45.   Widget form;       /* container */
  46.   Widget label;         /* label */
  47.   Widget attr_opt;   /* attribute option */
  48.   Widget attr_pop;   /* attribute option */
  49.   Widget op_opt;   /* operator option */
  50.   Widget op_pop;   /* operator option */
  51.   Widget value;      /* value option */
  52.  
  53.   Dimension width;    /* width  of the row */
  54.   Dimension height;   /* height of the row */
  55.  
  56.   MSG_ScopeAttribute scope;
  57.   MSG_SearchAttribute attr;
  58.   MSG_SearchOperator  op;
  59.   MSG_SearchValueWidget type;
  60.   int32 value_option;  /* for the MSG value */
  61.   char *textValue;
  62.  
  63. } XFE_SearchElement;
  64.  
  65. typedef struct XFE_SearchRules
  66. {
  67.   /* Top Level Layout */
  68.   Widget searchLabel;
  69.   XFE_FolderDropdown *scopeOpt;
  70.   Widget scopeOptW;
  71.   Widget whereLabel;
  72.   Widget searchCommand;
  73.   Widget more_btn;
  74.   Widget less_btn;
  75.  
  76.   Widget commandGroup;
  77.  
  78.   Widget frame;
  79.   Widget form;
  80.  
  81.   MSG_ScopeAttribute scope;
  82.  
  83. } XFE_SearchRules;
  84.  
  85. typedef struct XFE_SearchResult
  86. {
  87.   Widget container;
  88.   Boolean expand;
  89. } XFE_SearchResult;
  90.  
  91. class XFE_MNSearchView: public XFE_MNListView
  92. {
  93. public:
  94.  
  95.     XFE_MNSearchView(XFE_Component *toplevel_component,
  96.                      Widget parent,
  97.                      XFE_Frame * parent_frame,
  98.                      XFE_MNView *mn_parentView,
  99.                      MWContext *context, MSG_Pane *p, 
  100.                      MSG_FolderInfo *selectedFolder = NULL, 
  101.                      Boolean AddGotoBtn = False);
  102.  
  103.   virtual ~XFE_MNSearchView();
  104.  
  105.   static const char* CloseSearch;
  106.   static const char* STOP;
  107.   static const char* SEARCH;
  108.   static const int kStop;
  109.   static const int kSearch;
  110.  
  111.   static const int MAILSEARCH_OUTLINER_COLUMN_SUBJECT;
  112.   static const int MAILSEARCH_OUTLINER_COLUMN_SENDER;
  113.   static const int MAILSEARCH_OUTLINER_COLUMN_DATE;
  114.   static const int MAILSEARCH_OUTLINER_COLUMN_PRIORITY;
  115.   static const int MAILSEARCH_OUTLINER_COLUMN_LOCATION;
  116.  
  117.   static const char *scopeChanged;
  118.  
  119.   virtual Boolean isCommandEnabled(CommandType command, void *calldata = NULL,
  120.                                    XFE_CommandInfo* i = NULL);
  121.   virtual Boolean handlesCommand(CommandType command, void *calldata = NULL,
  122.                                    XFE_CommandInfo* i = NULL);
  123.   virtual void doCommand(CommandType command, void *calldata = NULL,
  124.                                    XFE_CommandInfo* i = NULL);
  125.  
  126.   virtual void doViewLayout();
  127.   virtual void doLayout();
  128.  
  129.   /* Outlinable interface methods */
  130.   virtual void *ConvFromIndex(int index);
  131.   virtual int ConvToIndex(void *item);
  132.  
  133.   virtual char *getColumnName(int column);
  134.  
  135.   virtual char *getColumnHeaderText(int column);
  136.   virtual fe_icon *getColumnHeaderIcon(int column);
  137.   virtual EOutlinerTextStyle getColumnHeaderStyle(int column);
  138.  
  139.   virtual void *acquireLineData(int line);
  140.  
  141.   virtual void getTreeInfo(XP_Bool *expandable, XP_Bool *is_expanded, int *depth
  142. ,
  143.                            OutlinerAncestorInfo **ancestor);
  144.   virtual EOutlinerTextStyle getColumnStyle(int column);
  145.   virtual char *getColumnText(int column);
  146.   virtual fe_icon *getColumnIcon(int column);
  147.  
  148.   virtual void releaseLineData();
  149.  
  150.   virtual void Buttonfunc(const OutlineButtonFuncData *data);
  151.   virtual void Flippyfunc(const OutlineFlippyFuncData *data);
  152.   virtual void createWidgets(Widget formParent);
  153.  
  154.   virtual void toggleActionButtonState(Boolean on);
  155.  
  156.   static void  startCallback(Widget w, XtPointer clientData, XtPointer callData);
  157.   static void  newCallback(Widget w, XtPointer clientData, XtPointer callData);
  158.   static void  closeCallback(Widget w, XtPointer clientData, XtPointer callData);
  159.   static void  miscCallback(Widget w, XtPointer clientData, XtPointer callData);
  160.   static void  moreCallback(Widget w, XtPointer clientData, XtPointer callData);
  161.   static void  lessCallback(Widget w, XtPointer clientData, XtPointer callData);
  162.   static void  expandCallback(Widget w, XtPointer clientData, XtPointer callData);
  163.   static void  gotoFolderCallback(Widget w, XtPointer clientData, XtPointer callData);
  164.   static void  deleteMsgsCallback(Widget w, XtPointer clientData, XtPointer callData);
  165.   static void  exposeOutlinerHandler(Widget, XtPointer, XEvent*, Boolean*);
  166.   
  167.   void  stopSearch();
  168.   void  setFolderOption(MSG_FolderInfo *folderInfo);
  169.   void  gotoFolder(Widget w);
  170.   void  deleteMsgs();
  171.  
  172.  
  173.   XFE_CALLBACK_DECL(searchFinished)
  174.   XFE_CALLBACK_DECL(searchStart)
  175. protected:
  176.   virtual void     createCommandButtons();
  177.   virtual void  addDefaultFolders();
  178.   virtual void  buildHeaderOption();
  179.   virtual void  prepSearchScope();
  180.   virtual void  buildResultTable();
  181.   virtual void  clickHeader(const OutlineButtonFuncData *data);
  182.   virtual void  singleClick(const OutlineButtonFuncData *data);
  183.   virtual void  doubleClick(const OutlineButtonFuncData *data);
  184.   virtual void  miscCmd();
  185.   virtual void  handleClose();
  186.   virtual void  buildResult();
  187.  
  188.   void  createResultArea();
  189.   
  190.   // Protected data member to be shared with child class
  191.  
  192.   Visual*   m_visual;
  193.   Colormap  m_cmap;
  194.   Cardinal  m_depth;
  195.   Widget    m_content;
  196.   Widget    m_header;
  197.   Widget    m_displayArea;
  198.   Boolean   m_allocated;
  199.   Boolean   m_hasRightLabel;
  200.   Widget    m_searchBtn;         /* Search Btn */
  201.   Widget    m_newSearchBtn;     /* New Search Btn */
  202.   Widget    m_miscBtn;         /* will be save btn or help btn */
  203.   Widget    m_closeBtn;         /* Close Btn */
  204.   Boolean   m_hasResult;
  205.   XP_Bool   m_booleanAnd;       /* search all vs search any */
  206.  
  207.   int         m_count ;
  208.   /* Top Level Layout */
  209.   XFE_SearchRules   m_rules;
  210.   XFE_SearchResult m_result;
  211.   MSG_ResultElement *m_resultLine;
  212.   MSG_Pane     *m_searchpane;
  213.   XFE_MsgFrame    *m_msgFrame;
  214.   Widget    m_ruleContent;
  215.   Boolean    m_searchAll;
  216.   MSG_FolderInfo *m_folderInfo;
  217.   XFE_Dashboard *m_dashboard;
  218.   DIR_Server     *m_dir;
  219.   XFE_Frame * m_parentFrame;
  220.  
  221. private:
  222.  
  223.   void initialize();
  224.   void     createMoreLess(Widget);
  225.   void  createDisplayArea();
  226.   void  startSearch(Widget w);
  227.   void  resetSearch();
  228.  
  229.  
  230.   void  createMiniDashboard(Widget dashboardParent);
  231.   int   getNumFolderOptions();
  232.  
  233.   void  updateUI(Boolean allowSearch);
  234.   void  updateResultCount(int count);
  235.   void  setResultSensitive(Boolean sens);
  236.   
  237.   void     addRules(char *title, 
  238.         MSG_ScopeAttribute  curScope, 
  239.         uint16 curAttr);
  240.  
  241.   void  expand();
  242.   void  doExpand(Boolean doit);
  243.   void  moreRules();
  244.   void  lessRules();
  245.   void  setAllBooleans(Boolean andP);
  246.   void  setOneBoolean(int i);
  247.   void  newSearch();
  248.   void  turnOnStop(Widget w, Boolean turnOn);
  249.   void  addFolderOption();
  250.   char*    getNameFromScope(MSG_ScopeAttribute scope_num);
  251.   Boolean isOnStop(Widget w);
  252.   Boolean isMailFolder(MSG_FolderInfo* folderInfo);
  253.   XFE_CALLBACK_DECL(folderSelected)
  254.   void  selectFolder(MSG_FolderInfo *);
  255.   static void andOrCB(Widget w, XtPointer, XtPointer);
  256.  
  257.   Widget m_gotoBtn;
  258.   XFE_Button* m_fileBtn;
  259.   Widget m_deleteBtn;
  260.   Boolean m_addGotoBtn;
  261.   XFE_PopupMenu *m_popup;
  262.  
  263.   static MenuSpec popup_spec[];
  264. };
  265.  
  266. #endif
  267.  
  268.