home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / ABSearchDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.4 KB  |  141 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.    ABSearchDlg.cpp -- search dlg
  20.    Created: Tao Cheng <tao@netscape.com>, 22-oct-97
  21.  */
  22.  
  23. #include "ABSearchDlg.h"
  24.  
  25. #include <Xm/Form.h>
  26.  
  27. #include "xpgetstr.h"
  28.  
  29. #if 0
  30. static XFE_ABSearchDlg *theDlg =  NULL;
  31. #endif
  32.  
  33. XFE_ABSearchDlg::XFE_ABSearchDlg(Widget          parent,
  34.                                  char           *name,
  35.                                  Boolean         modal,
  36.                                  MWContext      *context,
  37.                                  ABSearchInfo_t *info):
  38.     XFE_ViewDialog((XFE_View *) 0, parent, name,
  39.                    context,
  40.                    False, /* ok */
  41.                    False, /* cancel */
  42.                    False, /* help */
  43.                    False, /* apply; remove */
  44.                    False, /* separator */
  45.                    modal)
  46. {
  47.     XP_ASSERT(info && info->m_dir);
  48.  
  49.     Arg av [20];
  50.     int ac = 0;
  51.  
  52.     /* Form: m_chrome is the dialog 
  53.      */
  54.     ac = 0;
  55.     XtSetArg (av [ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  56.     XtSetArg (av [ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  57.     XtSetArg (av [ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  58.     XtSetArg (av [ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  59.     // XtSetArg (av [ac], XmNresizePolicy, XmRESIZE_NONE); ac++;
  60.     Widget form = XmCreateForm(m_chrome, "abSearchDlgForm", av, ac);
  61.  
  62.     XtVaSetValues(m_chrome, /* the dialog */
  63.                   // XmNallowShellResize, FALSE,
  64.                   XmNnoResize, True,
  65.                   XmNdefaultButton, NULL,
  66.                   NULL);
  67.  
  68.     XFE_ABSearchView *view = new XFE_ABSearchView(this,
  69.                                                   form,
  70.                                                   context,
  71.                                                   info);
  72.     setView(view);
  73.     view->show();
  74.     view->registerInterest(XFE_ABSearchView::dlgClose,
  75.                            this,
  76.                            (XFE_FunctionNotification)dlgClose_cb);
  77. }
  78.  
  79. XFE_ABSearchDlg::~XFE_ABSearchDlg()
  80. {
  81.     if (m_view)
  82.         m_view->unregisterInterest(XFE_ABSearchView::dlgClose,
  83.                                    this,
  84.                                    (XFE_FunctionNotification)dlgClose_cb);
  85. }
  86.  
  87. XFE_CALLBACK_DEFN(XFE_ABSearchDlg, dlgClose)(XFE_NotificationCenter */*obj*/, 
  88.                                               void */*clientData*/, 
  89.                                               void */* callData */)
  90. {
  91.     cancel();
  92. }
  93.  
  94.  
  95. void XFE_ABSearchDlg::setParams(ABSearchInfo_t *info)
  96. {
  97.     XP_ASSERT(m_view);
  98.     ((XFE_ABSearchView *) m_view)->setParams(info);
  99. }
  100.  
  101. void XFE_ABSearchDlg::ok() 
  102. {
  103.     /* search button
  104.      */
  105.  
  106.     /* close */
  107.     cancel();
  108. }
  109.  
  110. void XFE_ABSearchDlg::cancel()
  111. {
  112.     XtDestroyWidget(getBaseWidget());
  113. }
  114.  
  115. /* C API
  116.  */
  117. extern "C"  void
  118. fe_showABSearchDlg(Widget          toplevel, 
  119.                    MWContext      *context,
  120.                    ABSearchInfo_t *info)
  121. {
  122.     XP_ASSERT(info);
  123. #if 0
  124.     if (!theDlg)
  125. #else
  126.         XFE_ABSearchDlg*
  127. #endif
  128.             theDlg = new XFE_ABSearchDlg(toplevel, 
  129.                                          "abSearchDlg",
  130.                                          True,
  131.                                          context,
  132.                                          info);
  133. #if 0
  134.     else
  135.         theDlg->setParams(info);
  136. #endif
  137.     
  138.     theDlg->show();
  139. }
  140.  
  141.