// // // // // // // // // // // // // //---------------------------------------------------------------------------- // // // wstreamtst.cc - Example Use of a Specialized IOstream //

Example Use of a Specialized IOstream

//

Writing into a Motif Text Widget

//
// // // The implementation and declaration of 'owstream' are found in the files // wstream.h // and // wstream.cc, // respectively. //

    // <!-*-C++-*- file: wstreamtst.cc --->
    // <!-------------------------------------------------------------------------->
    // <! Copyright (C) 1995 Dietmar Kuehl >
    // <!>
    // <! This file is free software; you can redistribute it and/or modify >
    // <! it under the terms of the GNU General Public License as published by >
    // <! the Free Software Foundation; either version 2 of the License, or >
    // <! (at your option) any later version. >
    // <!>
    // <! This program is distributed in the hope that it will be useful, >
    // <! but WITHOUT ANY WARRANTY; without even the implied warranty of >
    // <! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the >
    // <! GNU General Public License for more details. >
    //----------------------------------------------------------------------------
    // <HTML>
    // <HEAD>
    // <TITLE> wstreamtst.cc - Example Use of a Specialized IOstream </TITLE>
    // <H1>Example Use of a Specialized IOstream</H1>
    // <H2>Writing into a Motif Text Widget</H2>
    // <HR>
    // </HEAD>
    // <BODY>
    // The implementation and declaration of 'owstream' are found in the files
    // <A HREF="http://www.informatik.uni-konstanz.de/~kuehl/iostream/wstream.h.html">wstream.h</A>
    // and
    // <A HREF="http://www.informatik.uni-konstanz.de/~kuehl/iostream/wstream.cc.html">wstream.cc</A>,
    // respectively.
    // <HR>
    #include <X11/Intrinsic.h>
    #include <Xm/PanedW.h>
    #include <Xm/Text.h>
    #include <Xm/PushB.h>

    #include "wstream.h"
----------------------------------------------------------------------------

    static void	ExitCB(Widget, XtPointer ud, XtPointer)
    {
      static int flag = 9;
      ostream    *stream = (ostream *)ud;

      switch (flag--)
      {
        case 0:
          exit(0);
        default:
          (*stream) << endl;
          break;
      }
    }
----------------------------------------------------------------------------

    int	main(int ac, char **av)
    {
      XtAppContext app_con;
      Widget       top = XtAppInitialize(&app_con, "Test", 0, 0, &ac, av, 0, 0, 0);
      Widget       form = XtCreateManagedWidget("form", xmPanedWindowWidgetClass, top, 0, 0);
      Widget       text = XtVaCreateManagedWidget("Text", xmTextWidgetClass, form,
    				XmNwidth, 200, XmNheight, 200, 0, 0);
      Widget       button = XtCreateManagedWidget("Exit", xmPushButtonWidgetClass, form, 0, 0);

      owstream     tout(text, 1);
      tout << "hello, world";

      XtAddCallback(button, XmNactivateCallback, ExitCB, &tout);

      XtRealizeWidget(top);
      XtAppMainLoop(app_con);

      return 0;
    }
    // </PRE>
    // <HR>
    // Please send comments, suggestions, problem reports, bug fixes etc. to 
    // <BR>
    // <A HREF="http://www.informatik.uni-konstanz.de/~kuehl"><I>Dietmar Kühl</I></A>:
    // <A HREF="mailto:dietmar.kuehl@claas-solutions.de">Dietmar.Kuehl@claas-solutions.de</A>
    // </BODY>
    // </HTML>
    

Please send comments, suggestions, problem reports, bug fixes etc. to
This file is converted from C++ source to HTML using c++2html.