00001 // -*- C++ -*- 00002 /*************************************************************************** 00003 * 00004 * The IPPL Framework 00005 * 00006 * 00007 * Visit http://people.web.psi.ch/adelmann/ for more details 00008 * 00009 ***************************************************************************/ 00010 00013 // This example code is from the book: 00014 // 00015 // Object-Oriented Programming with C++ and OSF/Motif 00016 // by 00017 // Douglas Young 00018 // Prentice Hall, 1992 00019 // ISBN 0-13-630252-1 00020 // 00021 // Copyright 1991 by Prentice Hall 00022 // All Rights Reserved 00023 // 00024 // Permission to use, copy, modify, and distribute this software for 00025 // any purpose except publication and without fee is hereby granted, provided 00026 // that the above copyright notice appear in all copies of the software. 00029 00030 00032 // UIComponent.h: Base class for all C++/Motif UI components 00034 #ifndef ACLVIS_UICOMPONENT_H 00035 #define ACLVIS_UICOMPONENT_H 00036 #include <Xm/Xm.h> 00037 00038 // 00039 // If this is not set, bx and cgx assume an old base class. App generation 00040 // may not work at runtime. 00041 // 00042 #define cxx_bx_compat 00043 00044 // This structure is for capturing app-defaults values for a Class 00045 00046 typedef struct _UIAppDefault 00047 { 00048 const char* wName; // Widget name 00049 const char* cInstName; // Name of class instance (nested class) 00050 const char* wRsc; // Widget resource 00051 char* value; // value read from app-defaults 00052 } UIAppDefault; 00053 00054 // UIComponent Class 00055 class UIComponent { 00056 00057 private: 00058 00059 // Interface between XmNdestroyCallback and this class 00060 00061 static void widgetDestroyedCallback ( Widget, 00062 XtPointer, 00063 XtPointer ); 00064 00065 protected: 00066 00067 char *_name; 00068 Widget _w; 00069 00070 // Protect constructor to prevent direct instantiation 00071 00072 UIComponent ( const char * ); 00073 00074 void installDestroyHandler(); // Easy hook for derived classes 00075 00076 // Called by widgetDestroyedCallback() if base widget is destroyed 00077 00078 virtual void widgetDestroyed(); 00079 00080 // Loads component's default resources into database 00081 00082 void setDefaultResources ( const Widget , const String *); 00083 00084 // Retrieve resources for this clsss from the resource manager 00085 00086 void getResources ( const XtResourceList, const int ); 00087 00088 // Initialize the app defaults structure for a class 00089 00090 void initAppDefaults ( const Widget, const char *, UIAppDefault * ); 00091 00092 // Set the app defaults for an instance of a class 00093 00094 void setAppDefaults ( const Widget, UIAppDefault *, const char* inst_name = NULL); 00095 00096 public: 00097 00098 virtual ~UIComponent(); // Destructor 00099 00100 // Manage the entire widget subtree represented 00101 // by this component. Overrides BasicComponent method 00102 00103 virtual void manage(); // Manage and unmanage widget tree 00104 virtual void unmanage(); 00105 00106 Widget baseWidget() { return _w; } 00107 00108 // Public access functions 00109 00110 virtual const char * className(); 00111 }; 00112 00113 typedef struct _UICbStruct 00114 { 00115 UIComponent *object; // this pointer 00116 XtPointer client_data; // client data 00117 } UICallbackStruct; 00118 00119 #endif // ACLVIS_UICOMPONENT_H 00120 00121 /*************************************************************************** 00122 * $RCSfile: UIComponent.h,v $ $Author: adelmann $ 00123 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:34 $ 00124 * IPPL_VERSION_ID: $Id: UIComponent.h,v 1.1.1.1 2003/01/23 07:40:34 adelmann Exp $ 00125 ***************************************************************************/ 00126