Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtmail / MotifApp / CmdInterface.C
1 /* $XConsortium: CmdInterface.C /main/4 1996/04/05 16:48:53 mgreess $ */
2 /*
3  *+SNOTICE
4  *
5  *      RESTRICTED CONFIDENTIAL INFORMATION:
6  *      
7  *      The information in this document is subject to special
8  *      restrictions in a confidential disclosure agreement bertween
9  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
10  *      document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
11  *      Sun's specific written approval.  This documment and all copies
12  *      and derivative works thereof must be returned or destroyed at
13  *      Sun's request.
14  *
15  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
16  *
17  *+ENOTICE
18  */
19 ///////////////////////////////////////////////////////////////////////////////
20 //////////////////////////////////////////////////////////////////////////////
21 //         This example code is from the book:
22 //
23 //           Object-Oriented Programming with C++ and OSF/Motif
24 //         by
25 //           Douglas Young
26 //           Prentice Hall, 1992
27 //           ISBN 0-13-630252-1 
28 //
29 //         Copyright 1991 by Prentice Hall
30 //         All Rights Reserved
31 //
32 //  Permission to use, copy, modify, and distribute this software for 
33 //  any purpose except publication and without fee is hereby granted, provided 
34 //  that the above copyright notice appear in all copies of the software.
35 ///////////////////////////////////////////////////////////////////////////////
36 //////////////////////////////////////////////////////////////////////////////
37
38
39 ///////////////////////////////////////////////////////
40 // CmdInterface.C
41 /////////////////////////////////////////////////////////
42 #include "CmdInterface.h"
43 #include "Cmd.h"
44
45 CmdInterface::CmdInterface ( Cmd *cmd ) : UIComponent( cmd->name() )
46 {
47     _active = TRUE;
48     _cmd    = cmd;
49     cmd->registerInterface ( this );
50 }
51
52 void CmdInterface::executeCmdCallback ( Widget, 
53                                        XtPointer clientData,
54                                        XtPointer )
55 {
56     CmdInterface *obj = (CmdInterface *) clientData;
57     
58     obj->_cmd->execute();     
59 }
60
61 void CmdInterface::activate()
62 {
63     if ( _w )
64         XtSetSensitive ( _w, TRUE );
65     _active = TRUE;
66 }
67
68 void CmdInterface::deactivate()
69 {
70     if ( _w )
71         XtSetSensitive ( _w, FALSE );
72     _active = FALSE;
73 }