1<sect1 id="Public_Header_File"> 2<title>Public Header File</title> 3<para> 4The public header file contains declarations that will be required by any 5application module that needs to refer to the widget; whether to create 6an instance of the class, to perform an 7<xref linkend='XtSetValues' xrefstyle='select: title'/> 8operation, or to call a public routine implemented by the widget class. 9</para> 10<para> 11<!-- .LP --> 12The contents of the Template public header file, 13<filename class="headerfile"><X11/Xaw/Template.h></filename>, 14are: 15</para> 16<literallayout class="monospaced"> 17.. 18<!-- .CB --> 19<!-- .\".so ../../lib/Xaw/Template.h --> 20/* Copyright (c) X Consortium 1987, 1988 */ 21 22#ifndef _Template_h 23#define _Template_h 24 25/**************************************************************** 26 * 27 * Template widget 28 * 29 ****************************************************************/ 30 31/* Resources: 32 33 Name Class RepType Default Value 34 ---- ----- ------- ------------- 35 background Background Pixel XtDefaultBackground 36 border BorderColor Pixel XtDefaultForeground 37 borderWidth BorderWidth Dimension 1 38 destroyCallback Callback Pointer NULL 39 height Height Dimension 0 40 mappedWhenManaged MappedWhenManaged Boolean True 41 sensitive Sensitive Boolean True 42 width Width Dimension 0 43 x Position Position 0 44 y Position Position 0 45 46*/ 47 48/* define any special resource names here that are not in <X11/StringDefs.h> */ 49 50#define XtNtemplateResource "templateResource" 51 52#define XtCTemplateResource "TemplateResource" 53 54/* declare specific TemplateWidget class and instance datatypes */ 55 56typedef struct _TemplateClassRec* TemplateWidgetClass; 57typedef struct _TemplateRec* TemplateWidget; 58 59/* declare the class constant */ 60 61extern WidgetClass templateWidgetClass; 62 63#endif /* _Template_h */ 64<!-- .CE --> 65</literallayout> 66<para> 67<!-- .LP --> 68<!-- .sp --> 69You will notice that most of this file is documentation. The crucial 70parts are the last 8 lines where macros for any private resource names 71and classes are defined and where the widget class datatypes and class 72record pointer are declared. 73</para> 74<para> 75<!-- .LP --> 76For the "WindowWidget", we want 2 drawing colors, a callback list for 77user input and an 78<function>exposeCallback</function> callback list, and we will declare three 79convenience procedures, so we need to add 80</para> 81<literallayout class="monospaced"> 82<!-- .LP --> 83<!-- .sp --> 84<!-- .CB --> 85/* Resources: 86 ... 87 callback Callback Callback NULL 88 drawingColor1 Color Pixel XtDefaultForeground 89 drawingColor2 Color Pixel XtDefaultForeground 90 exposeCallback Callback Callback NULL 91 font Font XFontStruct* XtDefaultFont 92 ... 93 */ 94 95#define XtNdrawingColor1 "drawingColor1" 96#define XtNdrawingColor2 "drawingColor2" 97#define XtNexposeCallback "exposeCallback" 98 99extern Pixel WindowColor1( /* Widget */ ); 100extern Pixel WindowColor2( /* Widget */ ); 101extern Font WindowFont( /* Widget */ ); 102<!-- .CE --> 103</literallayout> 104<para> 105<!-- .LP --> 106Note that we have chosen to call the input callback list by the generic 107name, <function>callback</function>, rather than a specific name. If widgets that define 108a single user-input action all choose the same resource name then there 109is greater possibility for an application to switch between widgets of 110different types. 111</para> 112</sect1> 113