home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / ABListSearchView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  8.9 KB  |  303 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.    ABListSearchView.h -- view of user's mailfilters.
  20.    Created: Tao Cheng <tao@netscape.com>, 17-dec-96
  21.  */
  22.  
  23. #ifndef _ABLISTSEARCHVIEW_H_
  24. #define _ABLISTSEARCHVIEW_H_
  25.  
  26. #include "MNListView.h"
  27. #include "ABSearchView.h"
  28. #include "PopupMenu.h"
  29.  
  30. #include "Button.h"
  31. #include "addrbk.h"
  32.  
  33. typedef enum {AB_BOOK = 0,
  34.       AB_PICKER
  35. } eABViewMode;
  36.  
  37. class XFE_ABListSearchView: public XFE_MNListView 
  38. {
  39. public:
  40.   XFE_ABListSearchView(XFE_Component *toplevel_component, 
  41.                        Widget         parent,
  42.                        XFE_View      *parent_view, 
  43.                        MWContext     *context,
  44.                        XP_List       *directories);
  45.   virtual ~XFE_ABListSearchView();
  46.  
  47.   //
  48.   Widget makeFilterBox(Widget parent, XP_Bool stopBtn);
  49.  
  50.   // user/list functions
  51.   void undo();
  52.   void redo();
  53.   void delUser();
  54.   void newUser();
  55.   void newList();
  56.  
  57.   // Get and pack selection
  58.   ABAddrMsgCBProcStruc* getSelections();
  59.  
  60.   virtual void paneChanged(XP_Bool asynchronous, 
  61.                            MSG_PANE_CHANGED_NOTIFY_CODE notify_code, 
  62.                            int32 value);
  63.  
  64.   void changeEntryCount();
  65.   XFE_Outliner *getOutliner() { return m_outliner;}
  66.  
  67.   //
  68.   void    expandCollapse(XP_Bool expand);
  69.   //
  70.   void    selectLine(int line);
  71.   void    selectDir(DIR_Server* dir);
  72. #if defined(USE_ABCOM)
  73.   void    selectContainer(AB_ContainerInfo *containerInfo);
  74.   void    setContainerPane(MSG_Pane *pane);
  75.  
  76.   static AB_EntryType getType(AB_ContainerInfo *container, ABID id);
  77.   static AB_EntryType getType(MSG_Pane *abPane, MSG_ViewIndex index);
  78.  
  79.   static int ShowPropertySheetForEntryFunc(MSG_Pane  *pane,
  80.                                            MWContext *context);
  81. #endif /* USE_ABCOM */
  82.  
  83.     //
  84.  
  85.   DIR_Server *getDir() { return m_dir;}
  86.   ABook      *getAddrBook() { return m_AddrBook;}
  87.   ABPane     *getABPane() { return m_abPane;}
  88.  
  89.   virtual void stopSearch();
  90.   XP_Bool      isSearching() { return m_searchingDir;}
  91.  
  92.   // Sort
  93. #if defined(USE_ABCOM)
  94.   void           setSortType(AB_AttribID id);
  95.   AB_AttribID    getSortType();
  96. #else
  97.   void           setSortType(AB_CommandType type);
  98.   ABID           getSortType();
  99. #endif /* USE_ABCOM */
  100.   XP_Bool        isAscending();
  101.   void           setAscending(XP_Bool as);
  102.  
  103.  
  104.   /* this method is used by the toplevel to sensitize menu/toolbar items. 
  105.    */
  106.   virtual Boolean isCommandEnabled(CommandType cmd, 
  107.                                    void *calldata = NULL,
  108.                                    XFE_CommandInfo* m = NULL);
  109.  
  110.   /* used by toplevel to see which view can handle a command.  Returns true
  111.      if we can handle it. */
  112.   virtual Boolean handlesCommand(CommandType cmd, 
  113.                                  void *calldata = NULL, 
  114.                                  XFE_CommandInfo* i = NULL);
  115.  
  116.   /* this method is used by the toplevel to dispatch a command. */
  117.   virtual void doCommand(CommandType cmd, 
  118.                          void *calldata = NULL,
  119.                          XFE_CommandInfo* i = NULL);
  120.  
  121.   // The Outlinable interface.
  122.   virtual void    *ConvFromIndex(int index);
  123.   virtual int      ConvToIndex(void *item);
  124.  
  125.   //
  126.   virtual char      *getColumnName(int column);
  127.   virtual char    *getColumnHeaderText(int /* column */){ return 0;};
  128.   virtual fe_icon *getColumnHeaderIcon(int column);
  129.   virtual EOutlinerTextStyle 
  130.                    getColumnHeaderStyle(int column);
  131.   virtual EOutlinerTextStyle 
  132.                    getColumnStyle(int column);
  133.   virtual char    *getColumnText(int /* column */){ return 0;};
  134.   virtual fe_icon *getColumnIcon(int /* column */){ return 0;};
  135.  
  136.   //
  137.   virtual void     getTreeInfo(XP_Bool *expandable, 
  138.                    XP_Bool *is_expanded, 
  139.                    int *depth, 
  140.                    OutlinerAncestorInfo **ancestor);
  141.   //
  142.   virtual void     Buttonfunc(const OutlineButtonFuncData *data);
  143.  
  144.   virtual void     Flippyfunc(const OutlineFlippyFuncData *data);
  145.   //
  146.   virtual void     releaseLineData();
  147.   virtual void    *acquireLineData(int line);
  148.  
  149.   //
  150.   // Sub-Dialog Windows
  151.   void propertiesCB();
  152.   void editProperty();
  153.   void popupUserPropertyWindow(ABID entry, XP_Bool newuser,
  154.                    XP_Bool modal);
  155.   void popupListPropertyWindow(ABID entry, XP_Bool newuser,
  156.                    XP_Bool modal);
  157.  
  158.  
  159.   // callbacks
  160.   static void typeDownTimerCallback(XtPointer closure, XtIntervalId *);
  161.   static void typeActivateCallback(Widget, XtPointer, XtPointer);
  162.   static void typeDownCallback(Widget, XtPointer, XtPointer);
  163.   static void comboSelCallback(Widget, XtPointer, XtPointer);
  164.   static void searchCallback(Widget, XtPointer, XtPointer);
  165.  
  166.   static void expandCallback(Widget, XtPointer, XtPointer);
  167.   //
  168.   static void searchDlgCB(ABSearchInfo_t *clientData, void *callData);
  169.   //
  170.   // callback to be notified when allconnectionsComplete
  171.   //
  172.   void unRegisterInterested();
  173.   XFE_CALLBACK_DECL(allConnectionsComplete)
  174.  
  175.   void setLdapDisabled(XP_Bool b);
  176.   //
  177.   static const char *dirExpand; // toggle 2 pane ui
  178.   static const char *dirsChanged; // 
  179.   static const char *dirSelect; // select dir
  180.  
  181.   // icons for the outliner
  182.   static fe_icon m_personIcon;
  183.   static fe_icon m_listIcon;
  184.   static fe_icon m_securityIcon;
  185.  
  186. #if defined(USE_MOTIF_DND)
  187.     /* motif drag and drop interface. 
  188.      */
  189.     fe_icon_data        *GetDragIconData(int row, int column);
  190.     static fe_icon_data *getDragIconData(void *this_ptr,
  191.                                          int row, int column);
  192.     
  193.     void                 GetDragTargets(int row, int column, 
  194.                                         Atom **targets, int *num_targets);
  195.     static void          getDragTargets(void *this_ptr,
  196.                                         int row, int col,
  197.                                         Atom **targets, int *num_targets);
  198.  
  199.     char                *DragConvert(Atom atom);
  200.     static char         *dragConvert(void *this_ptr,
  201.                                      Atom atom);
  202.   
  203.     int                  ProcessTargets(int row, int col,
  204.                                         Atom *targets,
  205.                                         const char **data,
  206.                                         int numItems);
  207.     static int           processTargets(void *this_ptr,
  208.                                         int row, int col,
  209.                                         Atom *targets,
  210.                                         const char **data,
  211.                                         int numItems);
  212.  
  213.     /* no instance method needed for getDropTargets 
  214.      */
  215.     static void          getDropTargets(void *this_ptr,
  216.                                         Atom **targets, int *num_targets);
  217.  
  218. #else
  219.   // external entry
  220.   static void entryListDropCallback(Widget, 
  221.                                     void*, fe_dnd_Event, fe_dnd_Source*, 
  222.                                     XEvent*);
  223. #endif
  224.  
  225. protected:
  226. #if !defined(USE_MOTIF_DND)
  227.   // internal drop callback for addressbook drops
  228. #if defined(USE_ABCOM)
  229.   void        entryListDropCB(fe_dnd_Source*, XEvent *event);
  230. #else
  231.   void        entryListDropCB(fe_dnd_Source*);
  232. #endif /* USE_ABCOM */
  233.  
  234. #endif
  235.  
  236.   void    startSearch(ABSearchInfo_t *clientData);
  237.   int     addToAddressBook();
  238.   void    idToPerson(DIR_Server *pABDir, ABID id, PersonEntry* pPerson);
  239.  
  240.   XP_Bool m_ldapDisabled;
  241.  
  242.   //
  243.   virtual void clickHeader(const OutlineButtonFuncData *){};
  244.   virtual void clickBody(const OutlineButtonFuncData *){};
  245.   virtual void clickShiftBody(const OutlineButtonFuncData *){};
  246.   virtual void doubleClickBody(const OutlineButtonFuncData *){};
  247.  
  248.   // callbacks
  249.   virtual void typeDownCB(Widget w, XtPointer callData);
  250.   virtual void comboSelCB(Widget w, XtPointer callData);
  251.   virtual void searchCB(Widget w, XtPointer callData);
  252.   virtual void searchDlg(Widget w, XtPointer callData);
  253.  
  254.   // UI
  255.   void refreshCombo();
  256.   void layout();
  257.  
  258.   Widget        m_filterSearchBtn;
  259.   Widget        m_filterStopBtn;
  260.   Widget        m_filterDirCombo;
  261.  
  262.   Widget        m_filterBoxForm;    
  263.   Widget        m_collapsedForm;
  264.   Widget        m_filterPrompt;
  265.   //
  266.   XP_Bool       m_searchingDir;
  267.   char         *m_searchStr;
  268.  
  269.   XP_List      *m_directories;
  270.   DIR_Server   *m_dir;
  271.  
  272. #if defined(USE_ABCOM)
  273.   AB_ContainerInfo *m_containerInfo;
  274.   MSG_Pane         *m_abContainerPane;
  275. #endif /* USE_ABCOM */
  276.  
  277.   ABook        *m_AddrBook; 
  278.   ABPane       *m_abPane;
  279.  
  280.   ABID          m_entryID; /* entryID for current line */
  281.  
  282. #if defined(USE_ABCOM)
  283.     AB_AttribID m_sortType;
  284. #else
  285.   unsigned long m_sortType;
  286. #endif /* USE_ABCOM */
  287.   XP_Bool       m_ascending;
  288.  
  289. private:
  290.   // no need to reinvent the wheel if existing one rolls smoothly
  291.   Widget        m_expandBtn;
  292.     
  293.   ABSearchInfo_t *m_searchInfo;
  294.  
  295.   /* trigger search when time elapse
  296.    */
  297.   XtIntervalId    m_typeDownTimer;    
  298.  
  299.   XFE_PopupMenu *m_popup;
  300.   static MenuSpec view_popup_spec[];
  301. };
  302. #endif
  303.