home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / viewkit / xcontact / lib / OkLabeledComponent.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.5 KB  |  80 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. // OkLabeledComponent.c++ --
  18.  
  19.  
  20. #include "OkLabeledComponent.h"
  21. #include "OkArgs.h"
  22. #include "OkStr.h"
  23.  
  24. #include <Xm/Label.h>
  25. #include <Xm/Form.h>
  26.  
  27. #include <assert.h>
  28.  
  29.  
  30. template <class T>
  31. OkLabeledComponent<T>::OkLabeledComponent( const char* name, Widget parent, 
  32.                         Orientation ornt ) :
  33.   VkComponent( name )
  34. {
  35.   _baseWidget = XmCreateForm( parent, _name, NULL, 0 );
  36.   installDestroyHandler();
  37.  
  38.   OkArgs args( 3 );
  39.   args.set( XmNtopAttachment, XmATTACH_FORM );
  40.   if ( ornt == HORIZONTAL ) 
  41.     args.set( XmNbottomAttachment, XmATTACH_FORM );
  42.   args.set( XmNleftAttachment, XmATTACH_FORM );
  43.   _label = XmCreateLabel( _baseWidget, OkStr( _name )|"Label", 
  44.                 args.list(), args.count() );
  45.   XtManageChild( _label );
  46.  
  47.   _component = new T( OkStr( _name )|"Base", _baseWidget );
  48.   assert( _component );
  49.   if ( ornt == HORIZONTAL ) 
  50.     // This trick needed, cause Motif Scrolled<whatever> is brain dead.
  51.     XtVaSetValues( XtParent( _component->baseWidget() ) == _baseWidget ?
  52.         _component->baseWidget() : XtParent( _component->baseWidget() ),
  53.       XmNtopAttachment, XmATTACH_FORM,
  54.       XmNbottomAttachment, XmATTACH_FORM,
  55.       XmNrightAttachment, XmATTACH_FORM,
  56.       XmNleftAttachment, XmATTACH_WIDGET,
  57.       XmNleftWidget, _label,
  58.       NULL );
  59.   else
  60.     // This trick needed, cause Motif Scrolled<whatever> is brain dead.
  61.     XtVaSetValues( XtParent( _component->baseWidget() ) == _baseWidget ?
  62.         _component->baseWidget() : XtParent( _component->baseWidget() ),
  63.       XmNtopAttachment, XmATTACH_WIDGET,
  64.       XmNtopWidget, _label,
  65.       XmNbottomAttachment, XmATTACH_FORM,
  66.       XmNrightAttachment, XmATTACH_FORM,
  67.       XmNleftAttachment, XmATTACH_FORM,
  68.       NULL );
  69.   _component->show();
  70.  
  71.  
  72. }
  73.  
  74. template <class T>
  75. OkLabeledComponent<T>::~OkLabeledComponent()
  76. {
  77.   delete _component;
  78. }
  79.  
  80.