home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / Minibuffer.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.1 KB  |  84 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.    Minibuffer.cpp -- silly epoch easter egg.
  20.    Created: Chris Toshok <toshok@netscape.com>, 19-Feb-97
  21.  */
  22.  
  23.  
  24.  
  25. #include "Minibuffer.h"
  26. #include "ViewGlue.h"
  27.  
  28. #include <Xm/Text.h>
  29. #include <Xm/Form.h>
  30. #include <Xm/PushB.h>
  31. #include "felocale.h"
  32.  
  33. XFE_Minibuffer::XFE_Minibuffer(XFE_Frame *toplevel, Widget parent)
  34.     : XFE_Component(toplevel)
  35. {
  36.     m_parentFrame = toplevel;
  37.     m_textfield = XtVaCreateWidget("minibuffertext",
  38.                                    xmTextFieldWidgetClass,
  39.                                    parent,
  40.                                    NULL);
  41.  
  42.     XtAddCallback(m_textfield, XmNactivateCallback, textActivate_cb, this);
  43.     
  44.     setBaseWidget(m_textfield);
  45. }
  46.  
  47. XFE_Minibuffer::~XFE_Minibuffer()
  48. {
  49.     // nothing to do here.
  50. }
  51.  
  52. void
  53. XFE_Minibuffer::textActivate()
  54. {
  55.     char *text;
  56.  
  57.     text = fe_GetTextField(m_textfield);
  58.  
  59.     // This needs to be smart -- checking for parameters and parsing them into
  60.     // a CommandInfo struct.
  61.     m_parentFrame->doCommand(Command::intern(text));
  62.  
  63.     XtFree(text);
  64. }
  65.  
  66. void
  67. XFE_Minibuffer::textActivate_cb(Widget, XtPointer clientData, XtPointer)
  68. {
  69.     XFE_Minibuffer *obj = (XFE_Minibuffer*)clientData;
  70.  
  71.     obj->textActivate();
  72. }
  73.  
  74. void
  75. FE_ShowMinibuffer(MWContext *context)
  76. {
  77.     XFE_Frame *frame = ViewGlue_getFrame(XP_GetNonGridContext(context));
  78.  
  79.     if (!frame)
  80.         return;
  81.  
  82.     frame->doCommand(xfeCmdOpenMinibuffer);
  83. }
  84.