Graphics format %gr[options]
There are two colour modes for ClearWin+ drawing routines: (a) VGA colour
mode, designed to emulate the EGA and VGA palette registers and used to port
legacy code to Windows and (b) RGB colour mode, the native Windows
Initially, to assist in the porting of legacy code, the default colour mode was
set as VGA colour mode. However, it is recommended that all new programs
should use RGB colour mode and (from July 2013) this is the default. There are three ways to change the colour
1. The default is changed to VGA colour mode by calling
set_rgb_colours_default@(0) at the beginning of the program.
2. Alternatively, when creating a drawing surface using %gr - Graphics Region,
you can include the option VGA_COLOURS (see below).
3. In either case you can change the colour mode for a particular drawing
surface by calling use_rgb_colours@.
%gr can be followed by a list of options that is any valid combination of the
BLACK, WHITE, RED, BLUE, YELLOW, GREY (or GRAY)
Specifies the initial background colour of the drawing surface. Otherwise this
defaults to the background colour of the surrounding window.
Specifies the intial background colour of the drawing surface where rr
represents hexadecimal digits for the red component etc..
METAFILE_RESIZE USER_RESIZE KEEP_ASPECT_RATIO
Options specifying the behaviour of the graphics area as it is re-sized.
Selects RGB colour mode. This is the default for ClearWin+ releases after July
Selects VGA colour mode. This is the default for ClearWin+ releases before July
Specifies that mouse movements and mouse button releases should be notified to
the call-back function, not just clicks and double clicks.
Used with FULL_MOUSE_INPUT in order to enable a %pm - Popup Menu popup menu that is
Specifies the initial selection mode, that controls the behaviour when the
user presses the left mouse button and drags the mouse over the graphics area.
These options are useful for interactive programs.
A Win32-only option to enable software to access the in-memory copy of the
graphics area so as to modify it at the highest possible speed. This option is
particularly useful for image processing software.
Used with %sy - Dialog Style 3d styles to re-align the %gr border.
%gr - Graphics Region creates a 'control' that is a rectangular graphics area (a drawing
surface) that will be filled by subsequent calls to ClearWin+ drawing
routines. In the absence of %gr, using drawing surface routines causes
ClearWin+ to create a separate window containing a drawing surface together
with a button to close the window. This is analogous to the automatic creation
of a ClearWin window for standard Fortran I/O. The various options to
the %gr format are explained in this and subsequent sections of the chapter.
%gr takes two arguments that provide the pixel width and height of a
rectangular area. You may want to vary these values depending on the resolution
of the user's screen. The pixel width and depth of the screen is obtained by
calling clearwin_info@ using SCREEN_WIDTH and SCREEN_DEPTH.
The %gr options consisting of simple colour names (such as black) supply an
initial background colour that would otherwise default to the background colour
of the surrounding window.
This will draw a red line on a black background. In this example, %lw - Leave Window Open has been
used to leave the window open so that code to draw to the drawing surface
can follow. A alternative approach is to provide a startup call-back function
using %sc - OnShow Callback and to place the graphics code in the call-back. This approach is
usually preferred unless you need to use %lw - Leave Window Open for other reasons.
If more than one drawing surface is to be drawn (either within one
window, or on different windows) then a grave accent modifier is supplied to
%gr and a third argument is required to input an integer (called a handle) that
you provide. This handle is used in the subroutine select_graphics_object@ in
order to select the current drawing surface.
The following example creates two drawing surfaces and draws to each in
c ----Graphics handles are input values to %gr ---
Other drawing surfaces can be set up to write an image to memory or to
write output to the printer. The graphics calls in the above program can also
be used on such surfaces. Details appear later in this chapter and in
Using the printer.