home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / ABSearchView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  5.5 KB  |  188 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.    ABSearchView.h -- class definition for XFE_ABSearchView
  20.    Created: Tao Cheng <tao@netscape.com>, 23-oct-97
  21.  */
  22.  
  23. #ifndef _ABSEARCHVIEW_H_
  24. #define _ABSEARCHVIEW_H_
  25.  
  26. #include "MNView.h"
  27.  
  28. #include "dirprefs.h"
  29. #include "msg_srch.h"
  30.  
  31. typedef enum {AB_SEARCH_NONE = 0,
  32.               AB_SEARCH_BASIC,
  33.               AB_SEARCH_ADVANCED
  34. } eABSearchMode;
  35.  
  36. typedef struct {
  37.     MSG_SearchOperator  m_op;
  38.     MSG_SearchValue     m_attribNval;
  39.     XP_Bool             m_logicOp;
  40.  
  41.     Widget              m_ruleForm;
  42.  
  43.     Widget              m_attribOptMenu;
  44.     Widget              m_attribPopup;
  45.     Widget              m_opOptMenu;
  46.     Widget              m_opPopup;
  47.  
  48.     Widget              m_label;
  49.     Widget              m_textF;
  50. } ABSearchUIParam_t;
  51.  
  52. typedef struct _ABSearchInfo_t{    
  53.     void              *m_obj;
  54.     void              *m_cbProc;
  55.  
  56.     DIR_Server        *m_dir;
  57.     eABSearchMode      m_mode;
  58.     uint16             m_nRules;
  59.     ABSearchUIParam_t *m_params;
  60.     XP_Bool            m_logicOp;
  61. } ABSearchInfo_t;
  62.  
  63. typedef enum {AB_SEARCH_ATTRIB = 0,
  64.               AB_SEARCH_OP,
  65.               AB_SEARCH_VAL,
  66.               AB_SEARCH_CONNECTOR
  67. } eABSearchMenuType;
  68.  
  69. typedef struct {
  70.     int                 m_th;
  71.     eABSearchMenuType   m_type;
  72.     MSG_SearchMenuItem *m_menuItem;
  73.     void               *m_obj;
  74. } ABSearchUIHint_t;
  75.  
  76. typedef void (*ABSearchCBProc)(ABSearchInfo_t    *clientData, 
  77.                                void              *callData);
  78.  
  79. class XFE_ABSearchView : public XFE_MNView
  80. {
  81.  
  82. public:
  83.     XFE_ABSearchView(XFE_Component  *toplevel_component,
  84.                      Widget          parent,
  85.                      MWContext      *context,
  86.                      ABSearchInfo_t *info);
  87.     ~XFE_ABSearchView();
  88.  
  89.     void        setParams(ABSearchInfo_t *info);
  90.  
  91.     /* CB
  92.      */ 
  93.     static void textFActivateCallback(Widget w, XtPointer clientData, 
  94.                                   XtPointer callData);
  95.     static void okCallback(Widget w, XtPointer clientData, 
  96.                                   XtPointer callData);
  97.     static void cancelCallback(Widget w, XtPointer clientData, 
  98.                                   XtPointer callData);
  99.     static void toggleSearchModeCallback(Widget w, 
  100.                                          XtPointer clientData, 
  101.                                          XtPointer callData);
  102.  
  103.     static void moreCallback(Widget w, XtPointer clientData, 
  104.                                   XtPointer callData);
  105.     static void fewerCallback(Widget w, XtPointer clientData, 
  106.                                   XtPointer callData);
  107.     static void clearCallback(Widget w, XtPointer clientData, 
  108.                                   XtPointer callData);
  109.     static void optValChgCallback(Widget w, XtPointer clientData, 
  110.                                   XtPointer callData);
  111.  
  112.     //
  113.     static const char *dlgClose; // cancel btn is hit.
  114.  
  115. protected:
  116.     void                textFActivateCB(Widget w, XtPointer callData);
  117.     void                okCB(Widget w, XtPointer callData);
  118.     void                cancelCB(Widget w, XtPointer callData);
  119.     void                toggleSearchModeCB(Widget w, 
  120.                                            XtPointer callData);
  121.  
  122.     void                moreCB(Widget w, XtPointer callData);
  123.     void                fewerCB(Widget w, XtPointer callData);
  124.     void                clearCB(Widget w, XtPointer callData);
  125.  
  126.     void                optValChgCB(Widget w, XtPointer callData);
  127.     //
  128.     void                toggleSearchMode(ABSearchInfo_t *info);
  129.     Widget              makeOptMenu(Widget            parent, 
  130.                                     int               num,
  131.                                     ABSearchUIHint_t *hint,
  132.                                     XtCallbackProc    cb,
  133.                                     Widget           *w);
  134.     Widget              rebuildOptChildren(Widget            parent,
  135.                                            int               num, 
  136.                                            ABSearchUIHint_t *hint,
  137.                                            XtCallbackProc    cb);
  138.  
  139.  
  140.     //
  141.     void                getAttribNames();
  142.  
  143.     void                add1Rule(MSG_SearchAttribute  a = kNumAttributes,
  144.                                  MSG_SearchOperator   op = kNumOperators,
  145.                                  char                *string = NULL);
  146.  
  147.     void                remove1Rule();
  148.  
  149.     void                getParams();
  150.     ABSearchUIHint_t   *getOptMenuHint(uint16 th, uint16 *num);
  151.  
  152.     char*               getValByAttrib(ABSearchUIParam_t *params, 
  153.                                        int nParams, MSG_SearchAttribute attrib);
  154. private:
  155.  
  156.     DIR_Server         *m_dir;
  157.  
  158.     eABSearchMode       m_mode;
  159.     ABSearchInfo_t     *m_searchInfo;
  160.     Widget              m_rulesRowCol;
  161.     Widget              m_searchRulesPrompt;
  162.     Widget              m_dirPrompt;
  163.     Widget              m_workForm;
  164.  
  165.     ABSearchUIParam_t  *m_params;
  166.     uint16              m_nRules;
  167.     uint16              m_nAllocted;
  168.  
  169.     Widget              m_modeToggle;
  170.  
  171.     MSG_SearchMenuItem *m_attrItems;
  172.     uint16              m_nAttribItems;
  173.  
  174.     Widget              m_ruleCmdGroupForm;
  175.     Widget              m_moreBtn;
  176.     Widget              m_fewerBtn;    
  177.     Widget              m_clearBtn;    
  178.  
  179.     Widget              m_andOrForm;
  180.     Widget              m_andOrOptMenu;
  181.     Widget              m_andOrPopup;
  182.  
  183.     void cleanupUI(uint16 i, XP_Bool clearRule);
  184.     void setOptMenu(Widget w, int16 attrib);
  185. };
  186.  
  187. #endif /* _ABSEARCHVIEW_H_ */
  188.