From 272e57235cd60a2e65ac8258d96a02eb3939b687 Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 25 Mar 2011 10:41:05 +0000 Subject: git update until 25 Mar 2011 xserver fontconfig glproto libXau libXft libXmu libfontenc libxcb mesa mkfontscale pixman randrproto xkeyboard-config xtrans xwininfo updated following packages: xproto-7.0.21 xineramaproto-1.2.1 libXt-1.1.1 libxkbfile-1.0.7 libXpm-3.5.9 libXfont-1.4.3 libXaw-1.0.9 bdftopcf-1.0.3 encodings-1.0.4 fixesproto-5.0 font-adobe-100dpi-1.0.3 font-adobe-75dpi-1.0.3 font-adobe-utopia-100dpi-1.0.4 font-adobe-utopia-75dpi-1.0.4 font-adobe-utopia-type1-1.0.4 font-alias-1.0.3 font-arabic-misc-1.0.3 font-bh-100dpi-1.0.3 font-bh-75dpi-1.0.3 font-bh-lucidatypewriter-100dpi-1.0.3 font-bh-lucidatypewriter-75dpi-1.0.3 font-bh-ttf-1.0.3 font-bh-type1-1.0.3 font-bitstream-100dpi-1.0.3 font-bitstream-75dpi-1.0.3 font-bitstream-speedo-1.0.2 font-bitstream-type1-1.0.3 font-cronyx-cyrillic-1.0.3 font-cursor-misc-1.0.3 font-daewoo-misc-1.0.3 font-dec-misc-1.0.3 font-ibm-type1-1.0.3 font-isas-misc-1.0.3 font-jis-misc-1.0.3 font-micro-misc-1.0.3 font-misc-cyrillic-1.0.3 font-misc-ethiopic-1.0.3 font-misc-meltho-1.0.3 font-misc-misc-1.1.2 font-mutt-misc-1.0.3 font-schumacher-misc-1.1.2 font-screen-cyrillic-1.0.4 font-sony-misc-1.0.3 font-sun-misc-1.0.3 font-util-1.2.0 font-winitzki-cyrillic-1.0.3 font-xfree86-type1-1.0.4 --- libXaw/specs/CH7.xml | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 libXaw/specs/CH7.xml (limited to 'libXaw/specs/CH7.xml') diff --git a/libXaw/specs/CH7.xml b/libXaw/specs/CH7.xml new file mode 100644 index 000000000..4c491704b --- /dev/null +++ b/libXaw/specs/CH7.xml @@ -0,0 +1,167 @@ + +Creating New Widgets (Subclassing) + +Although the task of creating a new widget may at first appear a little +daunting, there is a basic simple pattern that all widgets follow. The +Athena Widget library contains a special widget called the +Template widget that is intended to assist +the novice widget programmer in writing a custom widget. + + +Reasons for wishing to write a custom widget include: + + + + +Providing a graphical interface not currently supported by any existing +widget set. + + + + +Convenient access to resource management procedures to obtain fonts, +colors, etc., even if user customization is not desired. + + + + +Convenient access to user input dispatch and translation management procedures. + + + + +Access to callback mechanism for building higher-level application libraries. + + + + +Customizing the interface or behavior of an existing widget to suit a +special application need. + + + + +Desire to allow user customization of resources such as fonts, colors, +etc., or to allow convenient re-binding of keys and buttons to internal +functions. + + + + +Converting a non-Toolkit application to use the Toolkit. + + + + + +In each of these cases, the operation needed to create a new widget is +to "subclass" an existing one. If the desired semantics of the new +widget are similar to an existing one, then the implementation of the +existing widget should be examined to see how much work would be +required to create a subclass that will then be +able to share the existing class methods. Much time will be saved in +writing the new widget if an existing widget class Expose, Resize and/or +GeometryManager method can be used by the subclass. + + +Note that some trivial uses of a ``bare-bones'' widget may be achieved by +simply creating an instance of the Core +widget. The class variable to use when creating a Core widget is +widgetClass. +The geometry of the Core widget is determined entirely by the parent +widget. + + +It is very often the case than an application will have a special need +for a certain set of functions and that many copies of these functions +will be needed. For example, when converting an older application to use +the Toolkit, it may be desirable to have a "Window Widget" class that +might have the following semantics: + + + + +Allocate 2 drawing colors in addition to a background color. + + + + +Allocate a text font. + + + + +Execute an application-supplied function to handle exposure events. + + + + +Execute an application-supplied function to handle user input events. + + + + +It is obvious that a completely general-purpose WindowWidgetClass could +be constructed that would export all class methods as callbacks lists, +but such a widget would be very large and would have to choose some +arbitrary number of resources such as colors to allocate. An application +that used many instances of the general-purpose widget would therefore +un-necessarily waste many resources. + + +In this section, an outline will be given of the procedure to follow to +construct a special-purpose widget to address the items listed above. +The reader should refer to the appropriate sections of the +X Toolkit Intrinsics - C Language Interface +for complete details of the material outlined here. Section 1.4 of +the Intrinsics should be read in +conjunction with this section. + + +All Athena widgets have three separate files associated with them: + + + + +A "public" header file containing declarations needed by applications programmers + + + + +A "private" header file containing additional declarations needed by the +widget and any subclasses + + + + +A source code file containing the implementation of the widget + + + + + +This separation of functions into three files is suggested for all +widgets, but nothing in the Toolkit actually requires this format. In +particular, a private widget created for a single application may easily +combine the "public" and "private" header files into a single file, or +merge the contents into another application header file. Similarly, the +widget implementation can be merged into other application code. + + + +In the following example, the public header file +< X11/Xaw/Template.h >, +the private header file +< X11/Xaw/TemplateP.h > +and the source code file +< X11/Xaw/Template.c > +will be modified to produce the "WindowWidget" described above. +In each case, the files have been designed so that a global string +replacement of "Template" and "template" +with the name of your new widget, using +the appropriate case, can be done. + + + + + -- cgit v1.2.3