PDDR/2 - 32-Bit Plotter Presentation Driver

From EDM2
Jump to: navigation, search

Reprint Courtesy of International Business Machines Corporation, © International Business Machines Corporation

Printer Device Driver Reference

The Plotter Presentation Driver is a 32-bit vector graphics driver. Vector graphics drivers use drawing primitives, such as lines, arcs, boxes, circles, and area fills, to draw complex graphics images. The Plotter Presentation Driver relies on the graphics language capabilities of the printer or plotter to do the actual drawing.

For example, to draw a circle, the plotter driver sends the circle command with radius information to the printer. The printer has the responsibility of drawing the circle on the device.

The vector graphics languages that this driver supports are Hewlett-Packard Graphics Language (HP-GL and HP-GL/2) and IBM Graphics Language (IBM-GL). If the device or graphics language does not support the OS/2 drawing function, the driver will either call back to the graphics engine for simulation or convert the drawing function to a supported primitive. For example, an OS/2 FillPath call might be converted to a HP-GL/2 FillPolygon.

The Plotter Presentation Driver can also support devices that can mix HP-GL/2 and raster data such as laser printers or raster plotters. In the DEBUG version of the driver, a sample PCL laser printer is supported. The RETAIL and DEBUG versions of the driver support raster plotters using the HP-RTL language.

The files that comprise the Plotter Presentation Driver are PLOTTERS.DRV and PLOTTERS.HLP. PLOTTERS.DRV is the executable code and data of the driver. The PLOTTERS.DRV file exports OS2_PM_DRV_ENABLE, OS2_PM_DRV_DEVMODE, and OS2_PM_DRV_DEVICENAMES entry points. PLOTTERS.DRV has an extended attribute (EA) that must be present for the driver to be installed correctly. The PLOTTERS.HLP file contains the help panels for the Job Properties and Printer Properties dialog boxes of the driver.


Generic Printer Library (GenPLib)

The Generic Printer Library is a set of subroutines that are useful for 32- bit presentation drivers. The Plotter Presentation driver takes advantage of the following GenPLib functions:

  • Memory management routines
  • Multi-threading output capabilities
  • Error and debugging support routines

For further information about the Generic Printer Library, see Generic Printer Library.

Font Support

The example plotter driver code supports only one device font. The HP-GL/2 or IBM-GL font named Stick is the plotter driver's default font. This font is a fixed-spaced, scalable font. A fixed-spaced, scalable font is one that can be scaled to any character width and height by setting the character attribute CBB_BOX. As soon as the font is scaled, the width of all characters will be constant.

Changing the code to support another fixed-spaced, scalable font is not difficult and can be achieved through the following steps:

  1. Add a data structure to #PLOTTERS.C enumerating the FONTMETRICS information of each supported font.
  2. Change the PlotterClass data structure in #PLOTTERS.C to include a bit fields defining which fonts each device supports and the appropriate default font.
  3. Modify the #initialize_pdevice() function in #ENABLE.C to set the correct default device font.
  4. In #FONT.C, make #DeviceQueryFonts() return the additional fonts and make #RealizeFont() select the font.

Adding proportional-spaced fonts requires the following additional changes:

  1. In #FONT.C, modify #cpxfm_metrics() to scale the width of all the characters in the font.
  2. Change the character positioning functions #QueryTextBox(), #QueryWidthTable(), and #QueryCharPositions() to use the proportional font character width and kerning information.

The plotter driver uses a combination of the device name and the device class to support printers. The device name is the name of the device that is used to look up the corresponding device class information in the plotter driver's plotter definition table, PlotterDef[].

The PlotterClass data structure contains all the information describing the characteristics of the of the device.

The plotter driver currently supports the following devices and corresponding device classes:

IBM7375-1 CLASS_HP7585B
IBM7375-2 CLASS_HP7586B
DesignJet 600 CLASS_DESIGNJET600

To add a new device that will be supported by an existing class, complete the following steps:

  1. Add the device name to the PlotterDef[] table in #PLOTTERS.C.
  2. Add a define in DIALOG.H that defines a numeric constant for your device. The numeric constant will be used to load the device description string that you must add to the PLTUS.RC file.

To add a new device class to the plotter driver, complete the following steps:

  1. Add a new PlotterClass structure to PLOTTERS.C defining your new class.
  2. Add a define in PLOTTERS.H for the class.
  3. Add an entry to the PlotterDef[] table along with a device name that uses the class.

Plotter Modules and Functions

This section provides a layout of the Plotter Presentation Driver source code. Refer the DDK CD for the Plotter Presentation Driver source code and to the "Using Your DDK", also available on the DDK CD, for a roadmap of the file structure used by the source code.

The first part of this section lists in alphabetical order all functions found in the Plotter code. The module in which each function is found is listed next to the function.

The second part of this section lists the modules that comprise the Plotter driver and the functions that comprise each module. Each function is followed by a description.

Function List

Function Name Module Location
AccumulateBounds() BOUNDS.C
accumulate_line_bounds BOUNDS.C
addfxquad NEW.ASM
add_user_form FORMS.C
add_user_forms_to_list FORMS.C
adjust_char_attrs TEXTOUT.C
apply_clipping() CLIP.C
Arc (Exported) OUTPARC.C
arc_tan GLIB.ASM
band() BAND.C
BeginArea PATHS.C
begin_raster_graphics BITMAP.C
bin_output_bytes BITMAP.C
bitblt2 BITMAP.C
BoxBoth() BOX.C
BoxBoundary BOX.C
BoxInterior BOX.C
build_app_name DEVMODE.C
Build_Palette BITMAP.C
calc_bounds BOX.C
CharString TEXTOUT.C
CharStringPos TEXTOUT.C
check_area_background_color() COLOR.C
check_area_color() COLOR.C
check_char_background_color COLOR.C
check_char_color() COLOR.C
check_color_sorting COLOR.C
check_fill_type OUTPUT.C
check_line_color() COLOR.C
check_line_construction OUTPUT.C
check_marker_color() COLOR.C
check_menuitem DEVMODE.C
check_pen DEVMODE.C
check_pens DEVMODE.C
check_string_construction OUTPUT.C
choose_endpoints CLIP.C
CleanUpHelpStubHook DEVMODE.C
clear_entries DEVMODE.C
clear_memory UTILS.C
clear_patsym_area PATHS.C
clip_char TEXTOUT.C
close_file_or_device DOSIO.C
color_distance() COLOR.C
compare_memory UTILS.C
compress_adaptive COMPRESS.C
compress_any_supported_mode COMPRESS.C
constrain_hls COLOR.C
construct_char() CHARGEN.C
construct_chord_tolerance OUTPUT.C
construct_fixed OUTPUT.C
construct_float OUTPUT.C
construct_point OUTPUT.C
ConvertArcParams OUTPARC.C
convertbgr_to_rgb BITMAP.C
convert_color() COLOR.C
convert_list FORMS.C
convert_point OUTPUT.C
ConvertWithRotation UTILS.C
copy_device_info PROFILE.C
copymem INIT.ASM
copy_memory UTILS.C
copy_pen_option_info PROFILE.C
cpxfm_metrics FONT.C
create_default_color_table() COLOR.C
CreateLogColorTable() COLOR.C
delete_user_form FORMS.C
delete_user_forms_from_list FORMS.C
DeviceCreateBitmap() BITMAP.C
DeviceDeleteBitmap() BITMAP.C
DeviceGetAttributes() ATTRIBS.C
devicepalette COLOR.C
DeviceQueryFontAttributes() FONT.C
DeviceQueryFonts FONT.C
DeviceSelectBitmap() BITMAP.C
DeviceSetAttributes() ATTRIBS.C
DeviceSetCursor() BITMAP.C
DeviceSetDCOrigin() ATTRIBS.C
DeviceSetGlobalAttribute() ATTRIBS.C
disable_dc_begin ENABLE.C
disable_dc_complete ENABLE.C
disable_pdev ENABLE.C
DisJointLines OUTPLINE.C
display_carousel DEVMODE.C
display_colors DEVMODE.C
display_error FORMS.C
display_form_id FORMS.C
display_paper_size DEVMODE.C
display_pen DEVMODE.C
display_pens DEVMODE.C
display_user_form_paper_size FORMS.C
distance UTILS.C
download_pattern BITMAP.C
DrawBorder() BITMAP.C
draw_box BOX.C
draw_fullarc OUTPARC.C
DrawImage BITMAP.C
draw_line OUTPUT.C
DrawLinesInPath OUTPLINE.C
draw_patsym_diag PATHS.C
draw_patsym_horiz PATHS.C
draw_patsym_vert PATHS.C
draw_pattern_lines PATHS.C
draw_point OUTPUT.C
draw_polymarker_circle MARKER.C
draw_polymarker_cross MARKER.C
draw_polymarker_diamond MARKER.C
draw_polymarker_dot MARKER.C
draw_polymarker_eightpointstar MARKER.C
draw_polymarker_plus MARKER.C
draw_polymarker_sixpointstar MARKER.C
draw_polymarker_solidsquare MARKER.C
draw_polymarker_soliddiamond MARKER.C
draw_polymarker_square MARKER.C
enable ENABLE.C
enable_dc_begin ENABLE.C
enable_dc_complete ENABLE.C
end_doc OUTPUT.C
end_job OUTPUT.C
end_page OUTPUT.C
end_raster_graphics BITMAP.C
EnterDriver LOCKDDC.C
exchange_dispatch() DISPATCH.C
f_ldivf XFORMS.C
f_lsqrt XFORMS.C
fill_clip_area PATHS.C
fill_ldev ENABLE.C
fill_opt_end UTILS.C
fill_opt_init UTILS.C
FillPath PATHS.C
fill_pattern BITMAP.C
fill_pattern_Use_Device BITMAP.C
fill_pdev ENABLE.C
fill_pdev_save_dc_data ENABLE.C
fill_polygon PATHS.C
fill_the_clip_rectangles PATHS.C
find_device_name UTILS.C
find_printer_name UTILS.C
find_user_form_size FORMS.C
FindVectorLength FONT.C
flush_opt_buffer UTILS.C
free_memory UTILS.C
FullArcBoundary OUTPARC.C
FullArcInterior OUTPARC.C
fx_fxmulfx NEW.ASM
fxmultiply NEW.ASM
fxtofxquad NEW.ASM
get_angle OUTPUT.C
get_angle GLIB.ASM
get_angle_xform XFORMS.C
get_arc_center OUTPARC.C
get_area_attr_bundle() ATTRIBS.C
get_bounds() CLIP.C
get_char_attr_bundle() ATTRIBS.C
get_closest_color() COLOR.C
get_closest_pen COLOR.C
get_closest_point OUTPUT.C
get_color_group() COLOR.C
get_defaults PROFILE.C
get_device_id PROFILE.C
get_distance OUTPARC.C
get_group DEVMODE.C
get_ieee_addr DOSIO.C
get_image_attr_bundle() ATTRIBS.C
get_ini_comm_info DOSIO.C
get_line_attr_bundle() ATTRIBS.C
get_line_intersection OUTPARC.C
get_marker_attr_bundle() ATTRIBS.C
get_mod_handle UTILS.C
get_module_dir DEVMODE.C
get_new_outbuff DOSIO.C
get_perpendicular_bisect OUTPARC.C
get_printer_name PROFILE.C
get_profile PROFILE.C
get_quad_clip() CLIP.C
get_quadrant GLIB.ASM
get_string DEVMODE.C
GetBitmapBits() BITMAP.C
GetBitmapHandle BITMAP.C
GetBoundsData() BOUNDS.C
GetCurrentPosition OUTPLINE.C
GetExtraIncrements FONT.C
GetGreyPattern BITMAP.C
GetHorizTextAlignShift FONT.C
GetLineOrigin OUTPLINE.C
GetMeasureItemInfo DEVMODE.C
GetNextColor BITMAP.C
GetPairKerningTable TEXTOUT.C
GetStandardAlignment FONT.C
GetStyleRatio() ATTRIBS.C
GetVertTextAlignShift FONT.C
greyscalesourcebits BITMAP.C
HeightNumericSubProc FORMS.C
help_dialog_proc DEVMODE.C
HelpErrorFilter DEVMODE.C
HelpStubHook DEVMODE.C
id_conflicts FORMS.C
IDNumericSubProc FORMS.C
ImageData() BITMAP.C
image_scan BITMAP.C
ImageScan BITMAP.C
init_dialog DEVMODE.C
initfsrsem LOCKDDC.C
init_quad_clip CLIP.C
initialize_comm_port DOSIO.C
initialize_ddc() ATTRIBS.C
InitializeHelp DEVMODE.C
initialize_outputinfo DOSIO.C
initialize_pdevice ENABLE.C
initialize_user_forms FORMS.C
int_to_str UTILS.C
is_elipse OUTPARC.C
IsIta_COM_Port_Name UTILS.C
IsIta_Device_Name UTILS.C
LeaveDriver LOCKDDC.C
lift_pen OUTPUT.C
list_pen_options DEVMODE.C
list_pen_priority DEVMODE.C
llAddElement FORMS.C
llCreateElement FORMS.C
llDeleteElement FORMS.C
l_ldivfx NEW.ASM
llFindElement FORMS.C
llFreeAllElements FORMS.C
locate_HPGL2pen() COLOR.C
locate_pen() COLOR.C
locate_rfpen BITMAP.C
LockDevice() ATTRIBS.C
lstrcmp UTILS.C
lstrcpy UTILS.C
lstrlen UTILS.C
lstrncmp UTILS.C
lstrtoksrch UTILS.C
main_dialog_command DEVMODE.C
main_dialog_proc DEVMODE.C
measurement_to_string FORMS.C
merge_clip_rect() CLIP.C
modify_user_form FORMS.C
move_pen OUTPUT.C
name_conflicts FORMS.C
newton_f_lsqrt XFORMS.C
next_band OUTPUT.C
NotifyClipChange() CLIP.C
NotifyTransformChange XFORMS.C
number_of_hardcoded_forms ESCQUERY.C
number_user_forms_defined FORMS.C
open_file_or_device DOSIO.C
open_spooler_queue DOSIO.C
options_dialog_proc DEVMODE.C
OS2_DevPostDeviceModes DEVMODE.C
output_bytes DOSIO.C
output_clip_rect() CLIP.C
output_comma OUTPUT.C
output_number OUTPUT.C
output_point OUTPUT.C
PaintRegion PATHS.C
PartialArc OUTPARC.C
pencolor_dialog_proc DEVMODE.C
perform_std_spooling DOSIO.C
plot_line OUTPUT.C
PolygonSet PATHS.C
PolyMarker (Exported) MARKER.C
PolyScanline() OUTPLINE.C
PolyShortLine OUTPLINE.C
PolySpline OUTPARC.C
prdl_MemClipChange CLIP.C
priority_dialog_proc DEVMODE.C
prompt_for_carousel UTILS.C
prompt_for_page UTILS.C
putbuff_on_dataqueue DOSIO.C
quad_square_root NEW.ASM
quad_sort() CLIP.C
QueryCharPositions() FONT.C
QueryColorData() COLOR.C
QueryColorIndex() COLOR.C
QueryDeviceBitmaps() ESCQUERY.C
QueryDeviceCaps ESCQUERY.C
QueryDeviceNames() ESCQUERY.C
QueryDeviceResource ESCQUERY.C
querydevicesurface ENABLE.C
querydevresource2 ESCQUERY.C
QueryHardcopyCaps() ESCQUERY.C
QueryLogColorTable() COLOR.C
QueryNearestColor() COLOR.C
QueryRealColors() COLOR.C
QueryRGBColor() COLOR.C
QueryTextBox FONT.C
QueryWidthTable FONT.C
queue_opt_buffer UTILS.C
RealizeColorTable() COLOR.C
RealizeFont() FONT.C
rectl_intersect() CLIP.C
reduce_angle GLIB.ASM
ReleaseHelpStubHook DEVMODE.C
ResetBounds BOUNDS.C
reset_entries DEVMODE.C
reset_dc_state ENABLE.C
restore_dc_state ENABLE.C
RestoreScreenBits() BITMAP.C
return_driver_data UTILS.C
return_flat_user_forms_list FORMS.C
return_rf_fill_pen COLOR.C
rgb_to_hls() COLOR.C
return_to_HPGL2 BITMAP.C
rotate_4bpp_90 BITMAP.C
rotate_8bpp_90 BITMAP.C
rotate_bmap_90 BITMAP.C
round_divide UTILS.C
save_dc_state ENABLE.C
save_mod_handle UTILS.C
save_profile DEVMODE.C
SaveScreenBits() BITMAP.C
save_user_form FORMS.C
select_fill_pen() COLOR.C
select_fill_type() COLOR.C
select_HPGL2pen() COLOR.C
select_line_pen() COLOR.C
select_text_pen() COLOR.C
select_user_defined_pen() COLOR.C
send_header OUTPUT.C
send_trailer OUTPUT.C
SetArcParameters OUTPARC.C
set_arc_scale OUTPUT.C
set_area_attr_bundle() ATTRIBS.C
SetBitmapBits BITMAP.C
set_cell_angle TEXTOUT.C
set_cell_shear TEXTOUT.C
set_cell_size TEXTOUT.C
set_char_angle TEXTOUT.C
set_char_attr_bundle() ATTRIBS.C
set_char_italic_bold TEXTOUT.C
set_clip_rectangle() CLIP.C
SetCurrentPosition OUTPLINE.C
set_default_p1p2 OUTPUT.C
set_default_scale OUTPUT.C
set_empty_rect OUTPUT.C
set_graphics_position BITMAP.C
SetHelpStubHook() DEVMODE.C
set_HPGL2_color_palette COLOR.C
set_image_attr_bundle() ATTRIBS.C
set_line_attr_bundle() ATTRIBS.C
SetLineOrigin OUTPLINE.C
set_line_type OUTPUT.C
set_marker_attr_bundle() ATTRIBS.C
setmem INIT.ASM
set_mix_mode COLOR.C
set_p1p2 OUTPUT.C
Set_Palette BITMAP.C
set_pen() COLOR.C
set_pen_width() COLOR.C
set_raster_width_and_height BITMAP.C
set_rotation OUTPUT.C
set_scale OUTPUT.C
SetStyleRatio() ATTRIBS.C
set_transparency_mode() COLOR.C
setup_colors ENABLE.C
setup_raster_fill_index COLOR.C
square_root PRDMATH.ASM
sroot NEW.ASM
start_color_sorting() COLOR.C
start_doc OUTPUT.C
start_job OUTPUT.C
start_page OUTPUT.C
stop_color_sorting() COLOR.C
str_to_int UTILS.C
string_clip TEXTOUT.C
string_to_measurement FORMS.C
StrokePath PATHS.C
switchbetween_rgb_carousel DEVMODE.C
to_upper UTILS.C
ulNormalize PRDMATH.ASM
UnlockDevice() ATTRIBS.C
UnrealizeColorTable() COLOR.C
update_menu DEVMODE.C
user_defined_forms_dialog_proc FORMS.C
user_form_exists_exists FORMS.C
validate_any_color() ATTRIBS.C
validate_background_color() ATTRIBS.C
validate_background_mix() ATTRIBS.C
validate_foreground_color() ATTRIBS.C
validate_foreground_mix() ATTRIBS.C
vector_bitmap BITMAP.C
WidthNumericSubProc FORMS.C

Module and Function Descriptions

This section describes the modules that comprise the Plotter driver and the functions that comprise each module. Each function is followed by a description. The functions in each module are listed in alphabetical order.


This module contains plotter driver attributes.


Gets plotter driver attributes. This function is the entry point for external processes to obtain information about the current attributes of the plotter driver.


Sets plotter driver attributes. This function is the entry point for external processes to modify the current plotter driver attributes.


Sets the DC origin. The device origin is 0,0 when enabled. The device is responsible for adding this offset to all transformed coordinates. The plotter driver returns errors because SetDCOrigin is not journaled and would cause problems in color-sorting mode.


Sets the global attributes of different types of attributes.


Resets the presentation space.


Returns information from the current area attribute bundle according to the AttrsMask parameter.


Returns information from the current characterattribute bundle according to the AttrsMask parameter.


Returns information from the current image attribute bundle according to the AttrsMask parameter.


Returns information from the current line attribute bundle according to the AttrsMask parameter.


Returns information from the current marker attribute bundle according to the AttrsMask parameter.


Gets the Device Context origin. Assigns values to the coordinates.


Used for banding printers that use the display driver for writing into bit maps. The plotter returns 1:1.


Initializes device driver instance. Resets the device driver instance data structure to its base state.


Locks a device.


Sets area attributes.


Sets information from the current character attribute bundle according to the AttrsMaskparameter.


Sets image attributes.


Sets line attributes.


Sets marker attributes.


Sets the style ratio.


Allows all pending screen input or output operations that were blocked by #LockDevice() to continue.


Validates color.


Validates background color.


Validates background mix.


Validates foreground color.


Validates foreground mix.


This module contains the callback function passed to GenPLib banding routines.


Retrieves surfacebitmapinfo and fills the appropriate structures to internally call the #sdBitBlt function to output the surface.


This module contains bit-map related functions.


Sends the necessary commands to get into raster graphics transfer mode.

Note: Raster Mode may be either PCL or RTL.


Outputs binary data by calling the thread code to output the data on the second thread.

Note:This function should only be called after output_bytes has been called at least once. output_bytes makes sure the header information has been sent.


HPGL-1 devices

Transfers bit maps directly from memory. The plotter driver supports Bitblt only to bypass an optimization in the engine. This optimization causes the engine to use the driver's Bitblt() function to perform area fills. Therefore, you must verify that the function is the area fill (ROP_PATCOPY) , verify the options, and then continue. Anything else is rejected as if the function is not installed.

Note: This function was completely rewritten to support the Raster Operations.

HPGL-2 devices

The BitBlt function copies a bitmap from one presentation space to another. It can also modify the bitmap within a rectangle in a presentation space. The exact operation carried out by BitBlt depends on the raster operation specified by the Mix parameter.

If Mix directs BitBlt to copy a bitmap, the function copies the bitmap from a source presentation space specified by hdcSrc to a target presentation space specified by hDC. Each presentation space must be associated with a device context for the display, for memory, or for some other suitable raster device. The target and source presentation spaces can be the same if desired. The pXY parameter points to an array of points that specify the corners of a rectangle containing the bitmap in the source presentation space as well as the corners of the rectangle in the target presentation space to receive the bitmap. If the source and target rectangles are not the same, BitBlt stretches or compresses the bitmap to fit the target rectangle.

If Mix directs BitBlt to modify a bitmap, the function uses the raster operation to determine how to alter the bits in a rectangle in the target presentation space. Raster operations include changes such as inverting target bits, replacing target bits with pattern bits, and mixing target and pattern bits to create new colors. For some raster operations, the function mixes the bits of a bitmap from a source presentation space with the target and/or pattern bits.


This function is hooked for PCL color devices. If bitmap stretching is necessary, this function gets the bits from a bitmap and sends them to the device. If bitmap stretching is not necessary, this function calls back to the engine to get #sdBitBlt.


Sets the PCL/RTL Palette and outputs the necessary escape sequences to the device to build the Color Palette in the device.


Converts a source scan line from BGR format and to RGB order.


Creates a plotter driver bit map. This function is called to create a bit map of the specified form and to obtain its handle.


Deletes a plotter driver bit map. This function is called to destroy a specified bit map created by #DeviceCreateBitmap().


Selects a plotter driver bit map. This function tells the device driver that a new bit map is being selected into the given DC.


Sets the cursor bit map that defines the cursor shape. This function will return an error.


Downloads a user-defined pattern to the device for area fills. This function is called from #setup_raster_fill_index in #COLOR.C.


Draws a rectangle of bits.


Draws a border inside a rectangle and optionally fills the interior. This is a #Bitblt accelerator and will return an error.


Projects the image of a rectangle onto the source DC's bit map and onto the printer.


Sends the necessary commands to get out of raster graphics transfer mode.

Note: Raster Mode may be either PCL or RTL.


Sends the necessary commands to get the plotter into PCL or HPRTL mode. This is necessary to setup the device for a raster transfer.


Called from #Bitblt for ROP_PATCOPY. Fills a rectangle specified by the rclDst with the pattern bits in pBits.


Handles both HPGL2 and PCL to fill a rectangle with patterns. This function is called from #Bitblt for ROP_PATCOPY with user pattern.


Transfers bit map data from the specified DC to application storage. The DC must be a memory hDC with a bit map currently selected.


Returns the bit map handle.


Returns the pattern byte to the caller.


Reads source color bits and determines the number of pels that are the same color as the first pel. This function enables you to greyscale many pels at one time. This function returns the current RGB color and updates the pointers to the source bits, the current pel position, and the total number of continuous pels of the current RGB color.


Gets a pel from a position specified in world coordinates. This function returns -1 for error. Otherwise, it returns the color table index value for the pel.


Takes the current source bit map and converts the bit map into a greyscaled 1,1 bits into pBits.


Draws a row of image data.


Outputs the commands to transfer data to the device and transfers the data.


Outputs the commands to transfer data to the device and transfers the data.


Takes a color value in RGB format, looks through the currently defined pens for the color, and returns the pen number. If a pen with the same RGB color is not found, this function defines a new pen for the given color and returns that pen number.


Called from the new raster GRE if we hooked the function #querydevicesurface. This function prints an array of pre-clipped and pre-stretched bit maps.


Sends the necessary commands to set the position while in PCL or HPRTL mode.


Sends the necessary commands to set the source width. The destination width and height will only be set if you are scaling the bitmap.


Sets the Raster Fill index and the height and width of the rectangle. This function is called from #fill_pattern_Use_Device.


Restores a rectangle of bits saved by #SaveScreenBits(). Because this is a printer, the driver logs and error.


Sends the necessary commands to get the plotter back into HPGL mode from raster mode.

Note:Raster Mode may be either PCL or RTL.


Called from #rotate_bmap_90, this function rotates a bitmap 4 bits-per-pel by 90 degrees. This function assumes that the source is byte aligned.


Called from #rotate_bmap_90, this function rotates a bitmap 8 bits-per-pel by 90 degrees. This function assumes that the source is byte aligned.


Depending on the number of bits per pel, this function calls the appropriate function to rotate a bitmap by 90 degrees. This function currently supports only four and eight bit-per-pel bitmaps. This function is called from #fill_pattern_Use_Device and #download_pattern.


Saves a rectangle of bits from the screen. The plotter driver returns an error.


Sets a plotter driver bit map. This function transfers bit map data from application storage to the specified DC. The DC must be a memory hDC, with a bit map currently selected.


Sets a pel from a position specified in world coordinates. The plotters driver returns OK for this function.


Controls the PCL/RTL palette. This function performs the following:

  1. Saves the HPGL2 Palette, if it is not already saved.
  2. Sends the necessary configure image data command to the device. The configure image data command is based on the cBitCount of the bit map.
  3. Sets the number of bits per index in the Configure Image data command.
  4. Calls the Build_Palette to build the Palette.


Turns the bitmap into line commands for non-raster devices (pen plotters).


This module contains functions that control bounds accumulation.


Adds the given bounds into the existing bounds.


Determines the bounding box of the line whose end points are passed.


Returns bounds data to user. The units that are returned are specified by the parameters.


Resets either or both sets of bounding data.


This module contains functions associated with drawing boxes.


Draws the edges of a box and fills the interior. One corner is the current position, the other corner is supplied. The box can have rounded corners.


Draws the boundary lines of a box. The box can have rounded corners.


Draws the interior of a box. The box is drawn from the current position to a position supplied to the function. The box can have rounded corners.


Determines the bounding rectangle for the array of POINTLs given.


Generates the plotter command to draw a box from the current position to the given end point. The box can be a filled box or a boundary box.


This module contains output functions for device font characters.


Generates a sequence of commands to produce the desired character. Any manipulation that is required is performed, including switching to another character set.


This module contains clipping routines for the OS/2 Plotter Presentation Driver.


Determines the overall clipping rectangle and returns it to the caller. If the prIn of the passed-in rectangle is not zero, it is included. If the prIn of the passed-in rectangle is zero, it is ignored. The basic clipping information is obtained from the DDC.

Following are the three states of the clipping handles:

  • AC_RECT0 (Effectively) no clipping. prResult untouched.
  • AC_RECT1 One clip rectangle, returned in prResult.
  • AC_RECT2 Multiple clipping rectangles.


When this function is given the horizontal components (x) of four co-linear points that intersect a quadrilateral's extended boundary walls, it returns the values of the innermost two (those that span the interior of the figure ).


Returns the rectangular bounds (bounding box) of a point list.


Returns a rectangle of an arbitrary height extending above a given scan line. When bStart is true, the first scan line is processed. When bStart is false, the next scan line is processed.


Initializes the QCINFO structure supplied by the caller.


Merges the myriad of clip rectangles to produce the largest single rectangle that covers the area.


Called whenever an application requests to change any of the clipping bounds for the current PS/DC pair.


Sets the current soft clip limits at the plotter device.


  1. This routine is called from multiple locations within the driver. It is important not to modify the pClipRect data fields within the pPDevice portion of the driver instance data.
  2. If ClipComplexity == 0 and pPDevice->ClipComplexity == 1, the rectangle is a null rectangle.


Sets the clipping region of the shadow memory DC. This function copies the DC region of the DC and sets the same in the shadow memory DC. Therefore, both will be in sync.


Sorts the corner points of a quadrilateral into counter-clockwise order. The result is returned in the original array.


Intersects the last two parameters and returns the result in the first parameter.


Sets the current soft clip limits at the plotter device.


This module contains color/pen and pattern support functions for the OS/2 Plotter driver.


Checks the area background color and validates the capability of the plotter to output the current area fill color.


Checks the area color and validates the capability of the plotter to output the current area fill color.


Checks char background color and validates the capability of the plotter to output the current charbackground fill color.


Checks the character color and validates the capability of the plotter to output the current character color.


Determines the available pen color that is nearest to the requested color and uses this pen in direct mode. If you are playing back the journal file, you can only record the information.


Checks the line color and validates the capability of the plotter to output the current line color.


Checks the marker color and validates the capability of the plotter to output the current marker color/marker.


Returns the distance between two colors based on the HLS or RGB squaring system.


Constrains an HLS color to certain regions of the color wheel. If the color is grey, it is forced to white or black. If not, it is forced out to the rim of the wheel.


Accepts a color in the current device format and returns the RGB color.


Generates the default color table. This function is called at enable_dc time to create the default color table information. It can be called at reset_dc time to reinitialize the color table to its default state.


Creates a logical color table for the current device context.


This function currently does nothing except return true; however, it must remain hooked for the new graphics engine.


Gets the closest color to the RGB value passed in and returns the closest match currently available.


Returns the stall number of the pen that most closely matches the specified color. If RGBIn == WHITE, it returns 0.


Gets the color group and returns information about whether a pen is a paper pen, a transparency pen, or something else.


Finds the currently defined HPGL2 pen. If the pen is not yet defined, define a new pen. No priority is given to usage. This function should be called only if the user is using application colors (if (pSetup->usFlags & FL_USEAPPCOLORS) is set.


Finds the closest available pen color. Priority is assigned as follows:

  1. Lines
  2. Fills
  3. Text


Queries the current color data and returns information regarding the currently selected color support for the driver.


Queries the color index and returns the index of the RGB color value that most closely matches the RGBColorparameter.


Queries the logical color table.


Returns the available color nearest to the specified color on the currently associated device even if it is not available in the logical color table.


Returns an array of the distinct colors available on the device.


Returns the actual RBG color that results from the specified index. If the color index is in RGB mode, the nearest RGB color is returned.


Realizes the color table.


Returns the pen number for the RF instruction.


Converts an RGB color value to HLS format.

Note: Application colors should never be set with color sorting ON.


Selects the fill pen.


Selects the HPGL fill type that most closely matches the OS/2 pattern. Sets the direction of fill lines if this is supported on the particular plotter. Deciding whether or not to fill depends on the shape of the area being filled and the orientation of the paper. The fill type is a function of the direction to fill, the spacing between lines (currently 0 to default to pen thickness), and the type of line to draw (bi-directional). Bi-directional lines are not as precise as uni-directional, but uni-directional lines are much faster because the pen does not have to be lifted.


Selects the pen using the HPGL2 pens in the Dynamic Pen Palette (not the Carousel pens). This function is called when (pSetup->usFlags & FL_ USEAPPCOLORS) is set. This function generates the HPGL command to select a specified pen from the palette.


Selects the line pen and returns the stall number of the pen that most closely matches the Color parameter.


Selects the text pen.


Generates the HPGL command to select a specified pen.


Called during #send_header processing for HPGL2 devices only. Sets number of pens with the NPn; command, where n is the number of pens in the palette. If n is not a power of 2, the plotter uses the next larger power of 2.


Sets the Merge Control (ROP) in the device.


Sets the RGB of pen.


Generates the HPGL1 or HPGL2 command to set the pen width for HPGL2 or pen thickness for HPGL1.


Checks and sets the transparency mode (TR). TR defines how the white areas of graphics images are plotted. IN (initialize) and DF (default condition) instructions return TR to its default. White is defined as the white reference specified by the CR (color range) instructions.


Determines if the device supports user-defined patterns for area fills. If the device supports these patterns, this function gets the pattern bitmap handle from the graphics engine and calls the appropriate function to download the pattern bitmap to the device for area filling.


Sets up PLOTTERS to begin color sorting. Ensures the correct mode is not the first pass from spooler queue processor and that the user has selected color_sorting from the dialog box. This function is called to enable journaling for color sorting. It is called at enable time, and at each new page.


Stops color sorting. This function is called at the end of a page and the end of a frame. Its basic operation is to replay the journal file and perform only those operations requiring the current pen. Thus, all drawing operations are completed for each pen in one operation, thereby reducing the number of (slow) pen change operations. This function processes the color sorting information and is called at the end of a page. This function will stop journaling, then play the journal file for each pen used in the carousel. It will set the current pen based on lightness to darkness for a given carousel. If an ABORTDOC signal is received, the bEnableOutput flag will be cleared, further output will cease (output_bytes will stop sending) , and the rest of the journal file replay will be skipped.


Unrealizes the color table.


This module contains bit-map compression routines.


Block-based adaptive.

Compression for RTL.


Row-based compression.

Function will select the best compression supported by the device select the mode and output the data. This function will work for both RTL and PCL devices.


This module contains the functions for the Job Propertiesand Printer Propertiesdialog boxes.


Builds the app name from the printer driver and device names. For example, an app name of

PM_DD_Printer,PLOTTERS.LaserJet 4 HP-GL/2

is built from:

Printer name Printer

Driver name PLOTTERS

Device name Laserjet 4 HP-GL/2


Checks or unchecks a menu item in a menu. If status is TRUE, the menu item is checked. If status is FALSE, the menu item is unchecked.


Sets the check status in the PenColor and Type menu to bStatus. The check status is set only if a single pen is selected in the carousel configuration list box because this is the only time the items in these two pop-up menus will be checked.


Check the currently selected pens to see if the menu items must be enabled or disabled.


Exit list routine that ensures the removal of the stub HK_HELP hook before exiting.


Turns all items in the PenColor, Type, and Options menus to inactive (gray). This is required either when a new carousel is selected or the user does not have a pen selected in the carousel configuration list box.


Displays the currently selected carousel information in the static fields.


Determines the allowable colors and types that can be selected in the PenColor and Type pop-up menus. On entry, the menu status table for the PenColor menu is set to all TRUE (indicating any pen can be selected). The Type menu status table is initialized according to the pen types supported by the current plotter. Then, each pen that is selected in the carousel configuration list box is examined. If no pen is in the stall, no operation is performed. Otherwise, all PenColor menu items that the selected pen type does not support are made inactive (grayed). Likewise, all Type menu items that do not support the color of the given pen are made inactive (grayed). Finally the update menu function is called for the PenColor and Type pop-up menus.


Displays the current paper size in the main dialog box. If the paper size is A thru E or A4 thru A0, the dialog elements for the determination of the roll length are hidden and the current paper size is shown through static text. If the paper size is either a 24-inch or 36-inch roll, the paper size static message is hidden and the dialog elements for the roll length are shown. If roll feed is selected, the input focus of the main dialog is set on the roll length input box. The current paper size is then checked in the pop-up menu.


Displays a pen description for the given pen in the carousel text fields. The pen description consists of the pen color and the pen type.


Resets the contents of the carousel configuration list box for the current carousel. Because the display_pen function inserts its pen description at the specified position, a "dummy" string must be created for the duration of the carousel configuration construction. Once completed, this string is deleted. If any pens were selected prior to this construction, the check marks must be removed from the PenColor and Type menus and the PenColor, Type, and Options pop-up menus must be made inactive (grayed).


Retrieve the EA.VERSION from driver file.


Returns the group in which a pen is classified. (For example, P3 and P7 are paper pens; T3 and T6 are transparency pens.)


Returns the size of the directory path.


Loads the string number message from the resources file and places it in the message buffer in the DEVMODE structure. Returns the address of the string buffer in DEVMODE.


Calculates the height and width of the text string for the WM_MEASUREITEM message.


Dialog procedure for help.


Checks for a recoverable help manager initialization error. If a recoverable error is detected, a message box pops up. The message box describes the error and asks if the user wants to retry.


This hook is placed in the HK_HELP hook chain to catch the first time that the user presses PF1 or selects a Help push button. The driver then initializes the help instance and gets the user's help request passed back into the HK_HELP chain again by making a call to the private function WinCallHelpHook().


Initializes the main dialog box. This initialization is done upon entry and when the user changes the current plotter. This function performs the following duties:

  • Sets the window caption to the current plotter and checks it in the Plotter menu.
  • Checks the current and active carousels and displays the current carousel above the carousel configuration list box.
  • Initializes the paper feed selections and options.
  • Initializes the orientation selections.
  • Displays the current paper size.
  • Disables the PenColor, Type, and Options pop-up menus.
  • Constructs the carousel configuration list box.
  • Determines paper size support and updates the Size pop-up menu.


Initializes help. If an attempt to create a help instance has already been made, return immediately.


Displays (in the Pen Options dialog box) the value for the given option for each pen selected from the carousel configuration list box. The following are the available pen options:

  • Speed
  • Force
  • Acceleration

Speed and acceleration are true values. Force is an index in a table of values that is dependent upon the current plotter.


Displays (in the Pen Options dialog box) the priority for each pen selected from the carousel configuration list box. The following are the possible priorities:

  • NONE
  • LINE
  • FILL
  • TEXT


Handles the user interface of the main dialog box. This dialog box can only be enabled by the exported function DeviceMode. If something is processed, TRUE is returned. If nothing is processed, FALSE is returned.


Main dialog box window procedure where all window functions are processed. WM_COMMAND type functions are passed to the local function main_dialog_ command.


Handles the user interface of the pen options display and modification dialog box. The options that apply are:

  • Speed
  • Force
  • Acceleration


Called by applications that want to change the attributes of the driver, such as the device and pen configuration. OS2_DevPostDeviceModes gets the values based on the pszDeviceName passed from the OS2.INI file. The flags passed in determine the type of operation required by the caller, where bits 0-1 mean the following:

%00 - Display dialog, no update to the INI file
%01 - Display dialog, update INI file
%10 - Do not display dialog, just return INI information
%11 - reserved


Handles the user interface for selecting the pen color. Displays a list box of available pen colors and updates the main dialog with the color selection.


Handles the user interface for the display and modification of the pen priority. Each pen selected in the carousel configuration list box can be tagged with any of the following priorities:


For all fill output, a pen that has fill priority will be selected over another pen of the same color that does not have fill priority. Likewise, for all lines and text output, a pen that has lines and text priority will be selected over another pen of the same color that does not have lines and text priority.


Removes the stub HK_HELP hook from the hook chain, if it has been successfully added via #SetHelpStubHook().


Updates the PenColor and Type pop-up menus through a call to display colors , determines the options supported by the current plotter, and updates the Optionspop-up menu.


Saves the setup data in OS2SYS.INI. The setup data is placed in a private section of PLOTTERS and the record is identified by pszDeviceName. pszLogAddress (for example "IBM6180.PLOTTER1").


Adds the stub HK_HELP hook to the hook chain. This addition allows the driver to gain control the first time that the user presses PF1 or selects a Help push button.


Switches between RGB and carousel modes, depending on the user's choice in printer properties dialog box.


Copies a string from the source to the destination. If the string is null terminated, the copy stops when the terminator is hit. Otherwise, the copy continues for the number of bytes passed in.


Sets the status of a pop-up menu to the menu status table given by pMenuList. The three pop-up menus with menu status tables are:

  • PenColor
  • Type
  • Options


This file contains functions and macros that hook and unhook entries in the dispatch table.


Modifies the engine-supplied dispatch table.


UnHooks all the functions that are not mandatory and hooks all the mandatory functions. Provides support for bit map handling and memory DC.


This module contains the high-level output functions that communicate with the output thread code to output data to a file or device. See Output- Thread Management for further details.


Closes the output device.


Returns the IEEE address from the argument.


Extracts COM port modes from the OS2SYS.INI file.


Gets an output buffer from the head of the free queue or allocates a new one if no buffers are available on the free queue.


Sets the COM port to the conditions determined from the OS2.INI file.


Initializes outputinfo semaphores.


Opens the file name or device passed in. This file name or device is where the output will go. It can be a COM port, an IEEE port, or a disk file.


Sets up the connection to the spooler that the output has been sent to.


This function is a call that the driver uses to output data. This function calls Thread_Fill_Outbuff to put data on the output thread.


At the end of the spooling activities this function writes the metafile data to the spooler.


Puts the buffer on the end of the data queue (OutputInfo.obqData).


This module contains functions that are used when the device context is initialized or disabled.


This ENABLE subfunction is called before a DC starts its disable process. This function initiates any final clean up prior to the full disable, such as closing journaling, performing color sorting, and closing the spooler.


This ENABLE subfunction is called when a DC has completed the disable process. This function releases any memory that was allocated for the DC instance (pDDC).


This ENABLE subfunction is called when a physical device block is to be deleted. This function releases any memory that was allocated in #fill_pdev and closes the pathway to the device.


This function is the entry point OS2_PM_DRV_ENABLE for the plotter driver. This ENABLE function is exported by the device driver and performs the initialization of the device driver, the physical driver, and device contexts.


This ENABLE subfunction is called each time a DC is created. This is the first time the DC handle is presented and is the time to allocate the DC. The corresponding physical device pointer is the one that was returned in #fill_pdev.


This call informs the driver that the DC has been created by the graphics engine. It is the first time the pDDC that was returned in EnableDC is presented. At this time, this function opens the spooler if it is handling a queued DC. Any metafiles or journaling is started in this function.


This ENABLE subfunction is called when the driver is loaded and initializes the logical device block. This initialization includes setting some bits telling the engine that the driver needs a PDEV per DC and hooking the functions the driver will support.


This ENABLE subfunction is called each time a DevOpenDC is requested by the application. This function creates and allocates a physical device block, which should contain any information needed to perform I/O to the specified device.


Allocates memory from the pdevice block and saves the spooler parameters (if they exist) from the enable dc structure.


Initialize the device instance (PDevice) fields.


This routine is used by the graphics engine to query the device surface information. This function fills the DEVICESURFACE structure to be used by both the graphics engine and the device driver.


This ENABLE subfunction is called to reset a DC to its original initialized state.


This ENABLE subfunction is called when the engine wants the device driver to POP a saved DC or to POP to a specified DC.


This ENABLE subfunction is called when the engine wants a device driver to save all DC information. This function can be called multiple times, and the driver should push the DDC in LIFO order.


This function is called from #fill_pdev and sets up the color information for the selected plotter.


This module contains the functions for the exported entry points DevEscape, #QueryDeviceCaps, #QueryDeviceNames(), and #QueryHardcopyCaps().


Provides device-specific interface to the driver.


Gets information on the physical page size.

Extracts information about the physical page size. pPDevice points to the relevant entry in the PaperResTable and PrintOffTable for this particular plotter. The form is the number for the particular paper size. These range from 0 to 4 for sizes A to E (imperial), 5 to 9 for A4 to A0 (metric), 10 for a 24-inch roll, and 11 for a 36-inch roll.


Returns the number of forms available on this particular device.


Returns a list of bit map formats supported by the device. The plotter driver supports no bit maps, so this function sets the return data to zero out the return data area, as required.


Returns information about the device capabilities.

Information is returned to the caller in pData. Count items are returned, starting with the value Index. Values that are transform-sensitive are returned in DEVICE UNITS, such as the character size.


Returns information about the device names available from this driver, and about the datatypes handled. QueryDeviceNames() is a direct entry point into the driver. It bypasses the dispatch table mechanism because many applications will call this function without calling the enable functions to initialize the driver.


Called by the user at the time of setup to load all pointers and bit maps and called by the engine to load the default fonts, if any. This is a required function. The plotter driver returns zero, for "resource not available".


This function is called by the user on setup to load all pointers and bitmaps, and by the engine to load the default fonts (if there are any). This is a required function.


Returns information about the hardcopy capabilities of the device. Function either returns the number of forms available, or returns information about (selected) forms available.


This module contains the code and data for font support.


Copies fontmetrics from source to destination, up to count bytes. Any required transformations are applied.

Warning: This function overwrites the data at pMetricsSrc. If this data is valuable, it should be copied before this function is called.


Returns the font metrics for the currently selected font. If this is an engine font, the driver calls back. Otherwise, the driver copies to a local buffer, and then transforms the values from font notational to world space.


Returns information about the plotter's built-in fonts.


Finds the length of a given vector.


Calculates the amount of the space to increment between each character in a string. The application must use GpiSetCharExtra or GpiSetCharBreakExtra to enable the extra spacing.


Finds the text alignment shift in the horizontal direction, based on the usTextAlignment.


Finds the standard text alignment, based on the direction of the text.


Finds the text alignment shift in the vertical direction, based on the usTextAlignment.


Determines the origin of each character in the given string and adjusts for the character direction.


Queries text box for the given char string and returns the coordinate of the text box.


Returns information about the width of the characters in the currently selected font. If the current font is the hardware font of the plotter, information is returned from QueryWidthTable. Otherwise, the call is passed onto the engine because the engine knows more about fonts than QueryWidthTable.


Performs the following four functions:

  1. Realizes a device font.
  2. Realizes an engine font as a device font.
  3. Deletes a device font.
  4. Deletes an engine font realized as a device font.


This module contains functions that handle user-defined forms.


Queries the dialog. If the information is valid, it inserts that information into the linked list.


Determines how many user-defined forms exist for an application name, and then inserts each user-defined form name into the given list box. This function also allocates a user-defined form element and associates it to the newly created list box item.


Walks through the linked list and converts the integer measurements into a string form for the user to eventually see.


Queries the dialog for the current form, and then searches the linked list for that form. If it finds the form, it will delete it from the linked list.


Deletes any item that has a handle from the given list box. (Only user- defined forms should have this property.) Any user-defined form will be deleted from the list box and its associated memory will be freed.


Displays a message box that contains the string ErrorName with the ID ErrorMessage.


Given a linked list element, this function updates the window's name with that element's ID.


Given an element in a linked list, this function updates the dialog with the correct information.


Searches the INI file for that user-defined form ID and updates the printable X and Y mm sizes.


Subclassing procedure for an entry field. Its purpose is to allow only numeric input.


Walks through the linked list and searches for an element that has the same ID (it will not check against itself). If there is a conflict, it will return that element's form name.


Subclassing procedure for an entry field. Its purpose is to allow only numeric input.


Reads the user-defined forms into a linked list and returns the current unit of measurement and the number of forms that have been defined.


Adds an element that contains the given information into a linked list. To do this, the function creates an element, copies the information to it, and adds it to the linked list.


Allocates a linked list element off the heap in the instance data and initialize that element.


Given a linked list and a pointer to one of its elements, this function deletes that element from the linked list. This function also cleans up any resources used by that element.


Searches through the linked list for an element whose form name matches the form name that was given. If successful, it returns a pointer to that element.


Given a linked list, this function deletes every element in that linked list.


Converts an integer (in hundredths of a millimeter) into a string of a real numbers.


This function performs the following:

  1. Queries the dialog for the information that the user has entered
  2. Validates the information
  3. Searches the linked list for the form
  4. Changes the data that was stored in the linked list element to the data that the user has entered.


Walks through the linked list and searches for an element that has the same form name (it will not check against itself). If there is a conflict, it will return that element's form name.


Searches the OS2SYS.INI for the AppName entry and returns the number of forms that have been defined.


Searches the OS2SYS.INI for the application name and the user-defined forms entry. If there are no user-defined forms, it will return NULL. Otherwise, it will return the contents of the INI file entry.


Given a linked list, this function writes out the user-defined forms into the OS2SYS.INI file. If the number of forms is 0, it will delete the user- defined form information from the OS2SYS.INI file.


Converts the string representation of a real number into an integer representation. This integer will be in hundredths of a millimeter.


This is the dialog procedure for the user-defined forms.


Searches the user-defined forms in the INI file under the application name for the given form name.


Subclassing procedure for an entry field. Its purpose is to allow only numeric input.


This file contains trigonometric functions to calculate the sine, cosine, and arc tangent of an angle.


Returns the angle of the point in dx,ax in ax scaled by 10. The point is first scaled by Xaxis and Yaxis in order to handle an elliptical arc.


Given an origin and a point this function returns the arc tangent of point to the nearest tenth of a degree.


Given an Angle (0 - 3600) this function returns the cosine of the angle. The angle is assumed to be in tenths of a degree. The calculated cosine is scaled by 16384.


Given a point in ax,dx, this function determines arc tangent or angle of the given point. The angle is returned in ax.


Determines the quadrant of ax,dx and returns in cl.


Given a degree in si, this function returns cosine in ax scaled by 16384. Degrees range from 0 - 3600. bx,cx,dx are destroyed.


Given a degree in si, this function returns sine in ax scaled by 16384. Degrees range from 0 - 3600. bx,cx,dx are destroyed.


Reduces the angle in si to the range 0 - 90 * 10. It also determines the quadrant of the angle which is returned in cl.


Given an Angle (0 - 3600) this function returns the sine of the angle. The angle is assumed to be in tenths of a degree. The calculated sine is scaled by 16384.


This file contains ASM utility routines.


Copies memory is a manner similar to memcpy();.


Debugging routine to issue a software interrupt 3.


Sets memory to a value.


The plotter version of memset();.


This module contains the DLL initialization and termination functions.


Initializes the PMPLOT.DRV. Saves the HMODULE assigned from the operating system.


This file contains the lock and unlock code for the driver's instance data.


Entry to a hooked Gre function. Protects the pDDC while it is in the driver.


Initializes the semaphore structure.


Works with EnterDriver to ensure that threads with different IDs are not accessing the same pDDC. Exits from a hooked Gre function.


This module contains functions used to draw the supported marker types. Only PolyMarker is exported to the world.


Draws a small filled circle marker.


Draws a crosshaired PolyMarker.


Draws a diamond PolyMarker.


Draws a small filled circle marker.


Draws an eight-pointed PolyMarker.


Draws a plus-sign PolyMarker.


Draws a six-pointed PolyMarker.


Draws a filled square marker.


Draws a filled diamond marker.


Draws a square PolyMarker.

PolyMarker (Exported)

Draws a series of Markers at the specified locations.


This module contains functions that perform mathematical operations.


Adds two quad numbers.


Prepares the stack for fxmultiply and calls fxmultiply to multiply two FIXED numbers.


Multiplies two 32-bit fixed point numbers and returns a FIXED. FIXED is a signed 32-bit number with 16-bits of integer and 16-bits of fraction.


Converts a fixed long value to a fixed quad value.


Computes the SIGNED LONG quotient of a SIGNED LONG and a SIGNED FIXED.


Approximates the square root of an unsigned BIGFIXED.


Returns the square root of the given positive 32-bit value.


This file contains all the drawing routines used to create arc primitives for the plotter.

Arc (Exported)

Creates an arc using the current arc parameters and a pointer to two x,y coordinate pairs. The arc is drawn from the current position (a) through the first coordinate pair (b) to the second coordinate pair (c). Upon completion, the current position is updated to the end of the arc (c).


Outputs the chord tolerance for the Circle and Arc commands to the plotter, based on the radius received.


Converts the lQ and lP arc parameter values using the fixed multiplier and the current transform.


Draws a fullarc (circle or ellipse), given its center point and a radius. If Fill is TRUE, the fullarc is filled. Otherwise, it is outlined. Upon completion, the current physical pen position is at the center of the circle.

Note: This function should only be called for circles and not for ellipses.


Creates a FILLED and OUTLINED full arc with its center at the current position. A multiplier can be specified to apply to the current arc parameters. Upon completion, the current x,y position is not changed.


Creates an outlined full arc with its center at the current position. A multiplier can be specified to apply to the current arc parameters. Upon completion, the current x,y position is not changed.


Creates a FILLED full arc with its center at the current x,y position. A multiplier might be specified to apply to the current arc parameters. Upon completion, the current x,y position is not changed.


Returns the angle of a line in tenths of a degree.


Sets the center point of a circle defined by three points on the circumference of that circle.


Returns the distance, in specified coordinates, between the two given points.


Returns the intersection point of two lines defined by pPtsAB[0], pPtsAB[1] , pPtsCD[0], and pPtsCD[1]. This function returns TRUE if successful. Otherwise, it returns FALSE for "lines are parallel".


Returns line CD, which runs perpendicular to and bisects line AB.


Determines if an ellipse will be drawn instead of a circle.

Note: This code is copied from draw_fullarc. Any changes to draw_fullarc might have to be duplicated here.


Draws two figures:

  • A straight line from current position to the starting point of the partial arc
  • The arc, with its center at the specified point

A sweep angle of greater than 360 degrees is valid. After the line is drawn , a full arc is drawn, followed by a partial arc with a sweep angle of (sweep MOD 360) degrees. The current position is updated to the final point of the arc.


Draws a sequence of one or more Bezier splines starting at the current position. As each spline is drawn, the specified end point of the spline becomes the start point for the next spline. Upon completion, the current position is the end point of the last spline.


Sets up the scaling for the arc parameters.


Sets the arc parameters for subsequent arc, fullarc, partialarc functions.


This file contains all the primitive line drawing functions used by the Plotter.


Draws a sequence of disjoint straight lines. This is an optional function.


Loops through the given path and draws all lines it finds in that path. This is a required function.


Returns the logical pen position to the (X,Y) pointed to by pPts. The physical pen position (the actual location of the pen) might be different.


Returns the logical pen position to the (X,Y) pointed to by pPts. The physical pen position (the actual location of the pen) might be different.


Draws a series of connected lines, starting at the current position. The input is in world coordinates and the final position is at the last point.


Fills an area lying between polyshortline pairs by using the current pattern attribute. Notice that coordinates are passed as unclipped screen coordinates. Filling is inclusive at the left boundaries and exclusive at the right boundaries. The scan lines are ordered from bottom-to-top and from left-to-right.


Processes polyshortlines. A pointer to the shortline header is passed. Within the header, start points and stop points are specified. Following the header is an array of Xs (currently 16 bits). The curve starts at x0,y0 and ends at x1,y1. The number of x values is then determined by the absolute value of y1-y1+1. If y1 is greater than y0, y0 is incremented until it equals y1. If y1 is less than y0, y0 is decremented until it equals y1. The current position is not affected by this call.


Sets the current position to the supplied position. This value is recorded in both world and device coordinates, so that, if required, the values can be transformed into device coordinates.


Sets the current position to the supplied position. This value is recorded in both world and device coordinates, so that, if required, the values can be transformed into device coordinates.


This module contains utility routines for producing output on a vector plotter that supports HPGL.


Checks the currently set fill type.


Determines if the PS/DC pair has a line currently in construction.


Determines if a string label is currently in construction. If so, terminate the string label.


Given a fixed point number, this function outputs it as a floating number with up to 4 digits following the decimal point. Trailing zeroes after the decimal point are truncated. A simple 0 is output if the converted number is zero.


Generates a formatted floating point number for output to the plotter as part of command string. The number received by this function can have any number of decimal places. The multiplier parameter will determine the number of decimal places. For example, 2000 with a multiplier of 1000 = 2.0 and 2000 with a multiplier of 10000 = .20.


Outputs an (x,y) coordinate pair to the plotter, applying any needed transformation.


Converts a point to a different coordinate system.


Draws a line.


Draws a single point.


When the end of the current document has been reached, this function sends the necessary sequence of commands to prepare for the next document.


When the current plot job has ended, this function closes the relevant path.


If the current page of output is full, this function sends the appropriate command sequence to obtain a new page, and initializes it for output.


Given the three points A, B, and C, this function determines if B is closer to A than C.


Lifts the pen if it is not already lifted.


Updates the current physical position of the plotter pen or, if an area fill is being performed, updates the DDC's physical pen position information.


Enables a new band or calls end page if on the last band. Only roll feed plotters are banded.


Outputs a comma.


Outputs a number (integer implied) to the plotter as part of a command string.


Outputs a standard coordinate pair (x,y).


Plots a line from the current physical position or queues the line for later output if an area fill is currently in effect.


Sends prerequisite commands to the plotter to initialize the device for the next or new page.


Sends a command string that terminates a single page of output to the plotter.


Initializes the default plotting extents.


Sets the default scale for the current hardcopy device and media size.


Initializes a rectangle (RECTL) structure to enclose a null (unit) rectangle.


Sets up the active line type, such as dot-dash and dash.


Sets the current plotting extents.


Sets the current values for plotter-applied scaling.


Rotates the plotter coordinate system 90, 180, and 270 degrees.


Sets up the plotter for a new document. This function is called by start page, and is the second highest level initialization call. It initializes the beginning of a document (which is different from the beginning of a page because multiple pages might exist in a document).


Sends the necessary command sequence to start a plotter job.


Sends the necessary commands to setup the plotter for a new page of output.


This module contains path-related functions.


Indicates the beginning of a set of drawing operations to define an area boundary.


Called only for HPGL2 devices. This function depends on the code "set_color _palette()" in #COLOR.C to set pen 0 to white. If the area is not complex, it fills the area with a rectangle command. If the area is complex, it draws a series of horizontal white lines into the current clip path.


Draws a series of diagonal lines into the current clip path.


Draws a series of horizontal lines into the current clip path and sets up line endpoints, adding 1 to the right and subtracting 1 from the left to ensure that joining lines are clipped out.


Draws a series of vertical lines into the current clip path.


Draws a series of line patterns.


Indicates the end of the drawing operations defining the area.


Fills the currently selected clip path or clip region.


Fills the area by querying the outline of the path and filling the outline as a HPGL polygon. This function only fills the area if:

  • Clipping is simple. (1 clip)
  • Fill mode is alternate (FPATH_ALTERNATE)
  • Engine version is 2.02 or later

Current plotters can only handle 1 clip rectangles.


  1. Because older plotters have small polygon buffers, this method might not always work.
  2. On the 32-bit Engine (version 2.02 or greater), calling GreOutlinePath with the new option (NO_CLIPPING_REQD) results in a call to the DrawLinesInPath function for each unclipped subpath. On the 16-bit Engine, calling GreOutlinePath results in many calls to the PolyShortLine function for each subpath. Because the end of the subpath is too difficult to predict on the 16-bit engine or older versions of the 32-bit engine, the polygon filling method is used only on engine versions 2.02 or later.


Fills the area by filling the clip rectangles.

This code improves the speed of filling large simple areas.

Six clip rectangles was chosen for plotters because it included wide line boxes which produce four clip rectangles. More complex areas are not filled on plotters because filling an area with boxes does not optimize pen up (PU ) commands on normal plotters.

On HPGL2 devices, complex areas are filled entirely with this method.


Fills the path specified by the user.


Paints the specified region using the current area foreground and background colors. Mixing is controlled by the area foreground mix only.

The driver could handle the PaintRegion by calling GreGetRegionRects and filling the rectangles itself.


Draws a set of closed polygons. The polygons are filled using the current AREABUNDLE structure values. For the first polygon, the current position is the first point. For all subsequent polygons, all points that define the polygon are given explicitly. If necessary, the polygons are automatically closed by drawing a line from the last vertex to the first.


  • Polygons can overlap, if necessary.
  • This is a new function for 2.0.
  • GrePolygonSet is not valid when the COM_AREA or COM_PATH flag is set.

This function is called as a result of GpiPolygonSet and is called internally by DevicePolygonSet.


Converts the path to a wide line.

Note: The select_pen function in #COLOR.C will set the pen width to the geometric width if the instance variable pDDC->DCState.bWideLines is true. lineend and linejoin will be set in set_line_type if pDDC->DCState. bWideLines is set.


This module contains definitions of plotter characteristics for all supported plotters. The following structures are included in PLOTTERS.C:

  • PlotterClass
  • PlotterDef
  • usPlotterCount
  • PrintOffTable
  • PhysicalPageSize


This file contains ASM functions for data type FIXED point math.


Computes the FIXED quotient of two FIXED numbers.


Computes the FIXED product of two FIXED values.


Computes the Fixed square root of a Fixed. This routine simply pulls the parameter off the stack, puts it in EAX, and calls the square_root function.


Keeps track of the signs and calls idiv to perform the processing.


Computes the FIXED square root of a FIXED number.


Normalizes a ULONG so that the highest order bit 1 and returns the number of shifts performed. Also returns ZF=1, if the ULONG was zero.


This module is the interface to plotter-specific data. These functions access the information stored in the global data structures defined in PLOTTERS.C and retrieve and store data in the OS/2 INI file.


Returns the device characteristics for the requested plotter index.


Returns the pen option characteristics for the requested plotter index.


Fills the default set up data for the given plotter ID.


Matches the given name with the names of known devices, and then return the desired information.


Scans the PM_SPOOLER_PRINTER section of the OS2.INI file, looking for a printer attached to either the queue or logical address pointed to by pszLogAddress, and then looks for the queue name if this is a queued DC.

The format of OS2.INI file is:



  • device_name is the name in the Control Panel "Printer Connections" section
  • PORT is the serial/parallel port to which the device is connected, such as COM1
  • Driver.Type is the name of the driver (PLOTTERS in our case)
  • Type is the particular type of plotter, such as IBM6180
  • Queue is the name of the spooler queue associated with this device


Looks for the entry pDeviceName.pPrinter in the private section of the OS2SYS.INI file. This function contains initialization data for the particular type of plotter being used. A typical name is "IBM6180.PLOTTER1".


This module contains OS/2 plotter presentation driver text output functions and internal and external text-related output functions.


Adjusts the current character size and angles using the currently defined transforms.


Computes the character cell size for clipping purposes.


Outputs a character string, starting at the current position.


Outputs a character string at the specified point.


Handles complex clipping of a single character.


Returns the current code page.


This function is required to hook, but it is not supported.


Sets the angle character attribute.


Sets the shear angle character attribute.


Sets the cell size character attribute.


Sets the anglecharacter attribute.


Sets the italic and bold character attributes.


Sets the current code page.


Determines the clip limits of the supplied string information.


UTILS.C is a general utilities module.


Clears Size bytes of memory.


Compares memory at address pAddr1 with the memory at pAddr2, for Size bytes.


Converts an X length and a Y length, accounting for rotation.


C function to copy memory.

Note: The Assembler function cpymem is preferred.


Returns a value proportional to the plot distance between 2 points. The plot distance is defined as the larger of (delta x, delta y). This concept works with plotters because the pen can move in both directions at the same time. Therefore the time to move to a new position is determined solely by the larger of the X or Y distance.


Flushes any remaining buffered lines and releases memory.


Initializes the fill-optimization code.


Given a logical address (queue name, port name, or file name), this function returns the string containing the spooler's printer name. The caller must free this string (it is allocated off of the heap).


Given a logical address (spooler printer name, spooler device name, port name, or a UNC name), this function returns the string containing the spooler's printer name. The caller must free this string (it is allocated off of the heap).


Processes the contents of the area fill optimization buffer, drawing a minimal (not minimum) path through the accumulated line segments.


Deallocates memory from the heap or frees the memory from system.

C/Set Conversion: Four extra bytes from memory have been allocated to store a flag and the size of memory required.


Returns the module handle (hModule).


Converts the given integer to its character representation and returns the length of the string representing the integer. The integer can be positive or negative. The resulting string is assumed to describe a string of a length sufficient to hold the character representation of the integer and a trailing NULL. The resulting string will be at least MinDigitsin length.


Checks the physical port name. Any port name that begins with "COM" and is appended with any integer greater than or equal to 1 will be valid.


Checks that the physical device name is supported.


Compares the two strings for equality. This function ignores the case.


Copies from string pFrom to pTo.


Returns the length of the NULL-terminated string passed.


Compares the two strings for equality for a given length. This function ignores the case.


Searches for the Char token in the string pointed to by the input pointer, replaces this with a NULL, and updates the pointer past the NULL.


Prompts the user to insert the specified carousel.


Prompts the user to insert a sheet of paper.


Records a pair of points (line segment) in the area fill optimization buffer for processing when the buffer fills and is flushed.


Given a logical address (queue name, port name, or file name), this function searches for a plotter device name. It will place the device name string in pszDeviceName. If multiple plotter devices are attached to the printer (spooler term), the function will return the first one because there is no way to determine the proper one to select.


Divides two numbers and rounds up or down.


Called from the initialize routine when the driver is loaded. Its purpose is to save the handle to the module in a ring 2 data segment.


Converts an integer string to an integer value. The integer value is passed back through pInt. A pointer to the first position past the integer value in the string is returned as a result. Leading spaces are ignored and overflow is accounted for by this function.


Converts a character from uppercase to lowercase. This function will return valid driver data. It will also allocate a copy of driver data and initialize it to its default state. It is the caller's responsibility to free this data. If driver data was passed in, the function will check to see how much of that data can be copied over its initialized driver data.


This module contains conversion and transformation functions.

Divides a long by a FIXED, returning a FIXED.
Limitations This function was written specifically for generating the sine and cosine values in a triangle. As such, it might have restrictions not suitable for general use. The result is assumed to be less than or equal to 1.0000.
Returns the square root of the unsigned long argument. The value is returned as a FIXED number.
Generates a rotation matrix from character direction data.
Evaluates a square root using Newton's approximation method, using a fixed number of guesses.
Handles changes to the transformation matrixes as reported from the engine and returns the result of an indirect call to the GreNotifyTransformChange.

This function is called when the world->device transform is changed. Processing is as follows:

  1. Transform the current position.
  2. Then,
If it is outside the allowed 16-bit range, return an error.
If the position is OK, call the engine's entry point.

The pXformData structure specifies the new transform matrix.