Programming Guide


FocusLib Utility

 

FocusLib is a samples utility library that assists in setting up the native drawing context for the following:

A unique version of FocusLib.cpp and FocusLib.h exists for the OS/2, AIX, Windows platforms. The external interfaces to the FocusLib functions are similiar on all three platforms but the internal implementation of the FocusLib functions differs on the various platforms. The FocusLib utility is written to set up and return the following:

If you use any other graphics libraries, such as OpenGL, you may have to implement your own version of FocusLib for that graphics library. In this case, you should use the provided FocusLib utilities as an example of the steps necessary to set up the drawing context properly.

The example FocusLib utility sets up the clipping region and the window/viewport transformations for the returned device context. Use the FocusLib utility by calling its constructor, CFocus, passing it the facet, and optionally passing it a shape in which to draw. Declaring the CFocus object sets up the drawing context and stores the old state in the CFocus object itself (on the stack.) When its scope exits, the CFocus object's destructor is called, which restores the old state.

The following lists the FocusLib constructors available to sample parts on the various platforms.

OS/2 Platform

  CFocus::CFocus(ODFacet *facet, ODShape* invalShape, HPS *theHPS )
  CFocus::CFocus(ODFacet *facet, ODShape* invalShape, HPS *theHPS,
                 HRGN *theClipRgn)

Windows Platform

  CFocus::CFocus( ODFacet *facet, ODShape* invalShape, HDC *theHDC )

AIX Platform

  CFocus::CFocus( ODFacet *facet, ODShape* invalShape, GC *theGC )

The following is an example of CFocus on the OS/2 platform.

void DrawSomething( ODFacet *facet , ODShape *invalidShape)
{
#ifdef _PLATFORM_OS2_
HPS hps;
CFocus focus(facet, invalidShape, &hps);    // Creates a CFocus object on the
                                            // stack, which changes the focus
                                            // but stores the old state
...drawing code...(uses returned hps)...
#endif
}

The following is an example of CFocus on the Windows platform.

void DrawSomething( ODFacet *facet , ODShape *invalidShape)
{
#ifdef _PLATFORM_WIN32_
HDC hdc;
CFocus focus(facet, invalidShape, &hdc);    // Creates a CFocus object on the
                                            // stack, which changes the focus
                                            // but stores the old state
...drawing code...(uses returned hdc)...
#endif
}

The following is an example of CFocus on the AIX platform.

void DrawSomething( ODFacet *facet , ODShape *invalidShape)
{
#ifdef _PLATFORM_UNIX_
GC gc;
CFocus focus(facet, invalidShape, &gc);     // Creates a CFocus object on the
                                            // stack, which changes the focus
                                            // but stores the old state
...drawing code...(uses returned gc)...
#endif
}


[ Top | Previous | Next | Contents | Index | Documentation Homepage ]