g_win_r.c - Graphics WINdow Routines
This is the graphics windows subsystem. It supports plotting of a
DATA_REC data series as either HLC or OHLC bar charts with volume
bars and overlayed open interest plots. Or you can display candlestick
or equivolume charts. You can also overlay indicator plots on the
data chart. You also have complete control in plotting indicator
charts. You can plot histograms. Scaling is automatic or you can set
it manually. You can overlay as many items on a chart as you wish.
You have complete control over all plotting pens - they can be any of
16,777,216 colors, any width or plotting style. You also build
multi-chart windows with as many G_WIN inside a frame window as you
want. You can also use any TrueType font installed on your system.
You can also save any window to disk as a BMP file.
From a high level view a G_WIN is constructed by these data structures.
A single G_WIN struct controls the window construction information like
client sizes, data cnts, titles and WIN32 objects like brushes, dc's,
window handles and bitmaps. It then has 1 to N number of GDDS (Graphics
Display Data Series) records attached to it take provide the actual data
to be graphed and control the actual style of display.
Function
|
init_grfx_subsystem
|
Include file
|
G_WIN_R.H
|
Prototype
|
void init_grfx_subsystem( void )
|
Remarks
|
Allocate all the pens and the background brush for the grfx_subsystem.
|
Function
|
free_grfx_subsystem
|
Include file
|
G_WIN_R.H
|
Prototype
|
void free_grfx_subsystem( void )
|
Remarks
|
Do a DeleteObject() on all the pens of the subsystem.
|
Function
|
alloc_G_WIN
|
Include file
|
G_WIN_R.H
|
Prototype
|
G_WIN * alloc_G_WIN( void )
|
Remarks
|
Allocate and initialize a G_WIN struct. This routine will also call
init_grfx_subsystem to create the plotting pens.
|
Function
|
regGWINClass
|
Include file
|
G_WIN_R.H
|
Prototype
|
ATOM regGWINClass( G_WIN *gw_ptr )
|
Remarks
|
Register the G_WIN class with WIN32.
|
Function
|
GrfxWndProc
|
Include file
|
G_WIN_R.H
|
Prototype
|
GrfxWndProc( HWND hWnd , UINT mesg , UINT wParam , LONG lParam )
|
Remarks
|
This is the main WndProc for the graphics subsystem.
|
Function
|
create_g_window
|
Include file
|
G_WIN_R.H
|
Prototype
|
HWND create_g_window( G_WIN *gw_ptr , LPSTR window_title )
|
Remarks
|
Take the user initialized G_WIN ptr and create an actual window.
|
Function
|
free_g_window
|
Include file
|
G_WIN_R.H
|
Prototype
|
void free_g_window( G_WIN *gw_ptr )
|
Remarks
|
Free the memory of a G_WIN and all of its GDDS data items.
|
Function
|
clear_g_window
|
Include file
|
G_WIN_R.H
|
Prototype
|
void clear_g_window( G_WIN *gw_ptr )
|
Remarks
|
Use the background brush to clear a G_WIN.
|
Function
|
set_favorite_g_win_config
|
Include file
|
G_WIN_R.H
|
Prototype
|
void set_favorite_g_win_config( G_WIN *gw_ptr )
|
Remarks
|
Set the passed in G_WIN ptr to the current module defaults.
|
Function
|
set_g_win_defaults
|
Include file
|
G_WIN_R.H
|
Prototype
|
void set_g_win_defaults( int width , int height , int font )
|
Remarks
|
Set the module defaults for G_WINs.
|
Function
|
set_pen_defaults
|
Include file
|
G_WIN_R.H
|
Prototype
|
void set_pen_defaults( int pen_idx , int pen_style , int pen_width , COLORREF pen_color )
|
Remarks
|
Use this routine to modify the module defaults for the plotting pen array.
This routine must be called before init_grfx_subsystem() is called to create
the pens. The pen_idx is a enum value of type DF_PEN (defined in G_WIN_R.H).
The argument pen_style can be any valid windows PS constant and the pen_color
can be any RGB() value.
|
Function
|
create_gdds_data_rec
|
Include file
|
G_WIN_R.H
|
Prototype
|
GDDS * create_gdds_data_rec( int max_nodes , int node_cnt , DATA_REC *data )
|
Remarks
|
Allocate, initialize and return a new GDDS record for a DATA_REC data series.
The resulting GDDS record will cache its own copy of the data series of
max_nodes size. The data series will also be scanned and the max_dt_val &
min_dt_val set.
|
Function
|
insert_gdds_item
|
Include file
|
G_WIN_R.H
|
Prototype
|
void insert_gdds_item( G_WIN *gw_ptr , GDDS *gdds_ptr )
|
Remarks
|
Walk the list of GDDS records attached to a G_WIN ptr and hook the
passed in gdds_ptr to the end. And of course update the ptrs in the
gw_ptr. Also copy the gw_ptr->cht_flags into the gdds_ptr->cht_flags
if this is the first GDDS record in the chain since the fist record
controls scaling and display style.
|
Function
|
free_gdds_rec
|
Include file
|
G_WIN_R.H
|
Prototype
|
void free_gdds_rec( GDDS *gdds_ptr )
|
Remarks
|
Free the target GDDS record and any data series attached to it.
|
Function
|
create_gdds_ind
|
Include file
|
G_WIN_R.H
|
Prototype
|
GDDS * create_gdds_ind( int max_nodes , int node_cnt , float *data , HPEN draw_pen )
|
Remarks
|
Allocate, initialize and return a new GDDS record for a indicator data series.
The resulting GDDS record will cache its own copy of the data series of
max_nodes size. The data series will also be scanned and the max_dt_val &
min_dt_val set.
|
Function
|
create_gdds_horz_line
|
Include file
|
G_WIN_R.H
|
Prototype
|
GDDS * create_gdds_horz_line( float y_value , HPEN line_color )
|
Remarks
|
Allocate, initialize and return a new GDDS record for a horizontal line at
location - y_value draw with a pen color of - line_color.
|
Function
|
attach_data_rec_series
|
Include file
|
G_WIN_R.H
|
Prototype
|
void attach_data_rec_series( GDDS *gdds_ind_ptr , int max_nodes ,
int node_cnt , DATA_REC *data )
|
Remarks
|
Clone a DATA_REC data series and attached it to a given indicator data series
so that the date field in the DATA_REC can be used to label the x-axis.
|
Function
|
render_gdds_chain
|
Include file
|
G_WIN_R.H
|
Prototype
|
void render_gdds_chain( G_WIN *gw_ptr )
|
Remarks
|
This routine controls the rendering of all the attached GDDS records for a
given G_WIN. It also creates and destroys any user custom fonts and hits
the InvalidateRect() to cause Windows to generate a WM_PAINT msg so the
WndProc can copy the virtual bitmap to the users screen.
|
Function
|
render_gdds_data_rec
|
Include file
|
G_WIN_R.H
|
Prototype
|
void render_gdds_data_rec( G_WIN *gw_ptr , GDDS *gdds_ptr )
|
Remarks
|
This is the main drawing routine for the GDDS record of a DATA_REC data series.
This routine will set the plotting for the various chart types (like HLC bar vers
OHLC, candlestick, equivolume, overlays of volume and open interest) by checking
the cht_flags var and the DATA_REC open, volume, and open interest fields. It
will also calculate the scaling factors if the user has not set the manual scaling
vars. And of course last but not least - it will then draw the chart.
|
Function
|
render_gdds_ind
|
Include file
|
G_WIN_R.H
|
Prototype
|
void render_gdds_ind( G_WIN *gw_ptr , GDDS *gdds_ptr )
|
Remarks
|
This is the main drawing routine for the GDDS record of a indicator data series.
Plotting a float series is a little simpler - the only plot options are line
or histogram. If the GDDS record is the first in the chain - it will control
the window scaling else it is just overlayed on to the chart. This routine
will also label the x-axis with the date if a DATA_REC data series has been
provided.
G_WIN *lc_gw_ptr ;
lc_gw_ptr = ( G_WIN * ) gdds_ptr->gw_ptr ;
|
Function
|
render_gdds_horz_line
|
Include file
|
G_WIN_R.H
|
Prototype
|
void render_gdds_horz_line( G_WIN *gw_ptr , GDDS *gdds_ptr )
|
Remarks
|
Rendering this GDDS object is pretty simple - just draw_y_line.
|
Function
|
update_gdds_client_area
|
Include file
|
G_WIN_R.H
|
Prototype
|
void update_gdds_client_area( G_WIN *gw_ptr , GDDS *gdds_ptr )
|
Remarks
|
Update the plotting area size vars in the GDDS record by checking the actual
sizes in the G_WIN ptr (which automatically gets updated in the WndProc by
WM_SIZE msgs).
|
Function
|
check_gdds_data_range
|
Include file
|
G_WIN_R.H
|
Prototype
|
void check_gdds_data_range( GDDS *gdds_ptr )
|
Remarks
|
Make sure we have a useable range of y data. If the data range is
less than 1% - increase the actual min and max values by 5%.
|
Function
|
calc_dt_range
|
Include file
|
G_WIN_R.H
|
Prototype
|
void calc_dt_range( GDDS *gdds_ptr )
|
Remarks
|
Calculate the data range then calc the scaling increment and plot
scaling factor.
|
Function
|
set_high_lows
|
Include file
|
G_WIN_R.H
|
Prototype
|
void set_high_lows( GDDS *gdds_ptr , float *high_ptr , float *low_ptr , int loop_cnt )
|
Remarks
|
Find the highest_high and the lowest_low in the data series and store
them back into the caller's memory.
|
Function
|
calc_range
|
Include file
|
G_WIN_R.H
|
Prototype
|
void calc_range( GDDS *gdds_ptr , int interval_index , int loop_cnt )
|
Remarks
|
Find the best fit scale interval for the data series. This routine will
call itself recursively with loop_cnt in control of when to bail out.
|
Function
|
set_plot_range
|
Include file
|
G_WIN_R.H
|
Prototype
|
void set_plot_range( GDDS *gdds_ptr , float min_range , float max_range )
|
Remarks
|
Use this routine to force a chart to be plotted and scaled to your
specified min and max range values. This routine must be called before
the call to render_gdds_chain().
|
Function
|
round_as_int
|
Include file
|
G_WIN_R.H
|
Prototype
|
float round_as_int( float float_data , float interval , int fudge_factor )
|
Remarks
|
Convert a float to an integer, round it, then convert it back to a float
and return it.
|
Function
|
calc_dt_n_axis_scale_factors
|
Include file
|
G_WIN_R.H
|
Prototype
|
int calc_dt_n_axis_scale_factors( GDDS *gdds_ptr )
|
Remarks
|
Calculate the data range, plot scale factors and axis move increments.
Return TRUE if ok to plot else FALSE if not.
|
Function
|
build_axis_incs
|
Include file
|
G_WIN_R.H
|
Prototype
|
void build_axis_incs( GDDS *gdds_ptr )
|
Remarks
|
Calculate the axis plot increments based on number of data points and
number of scaling rows.
|
Function
|
set_x_inc
|
Include file
|
G_WIN_R.H
|
Prototype
|
void set_x_inc( int x_start , int x_stop , int num_of_cols )
|
Remarks
|
Calculate the x axis increment per data point.
|
Function
|
set_y_inc
|
Include file
|
G_WIN_R.H
|
Prototype
|
void set_y_inc( int y_start , int y_stop , int num_of_rows )
|
Remarks
|
Calculate the y axis increment per scale row.
|
Function
|
get_y_plot
|
Include file
|
G_WIN_R.H
|
Prototype
|
int get_y_plot( GDDS *gdds_ptr , float y_float )
|
Remarks
|
Return the calculated y plot location for the given data value.
|
Function
|
draw_empty_chart
|
Include file
|
G_WIN_R.H
|
Prototype
|
void draw_empty_chart( GDDS *gdds_ptr )
|
Remarks
|
Draw a virgin chart.
|
Function
|
GRX_grid
|
Include file
|
G_WIN_R.H
|
Prototype
|
void GRX_grid( GDDS *gdds_ptr , int x_start , int y_start , int x_stop , int y_stop ,
int num_of_cols , int num_of_rows , int box_the_grid )
|
Remarks
|
Multi-function grid and box draw routine. This routine is front-ended
by the following macros in G_WIN_R.H for various sub-functions, grid ( draws
a grid, boxed grid ( draw a grid and boxes it ), horz_dsh_lns ( draws
a series of horizontal dashed lines bounded by the x/y coordinates )
and vert_dsh_lns ( same as the last except vertical ). The x/y
coordinates are for the upper left corner ( x_start , y_start ) and the
lower right corner ( x_stop , y_stop ) of the desired area.
|
Function
|
GRX_box
|
Include file
|
G_WIN_R.H
|
Prototype
|
void GRX_box( GDDS *gdds_ptr , int x_start , int y_start , int x_stop , int y_stop )
|
Remarks
|
A simple draw a box around from upper left corner ( x_start , y_start )
to the lower right corner ( x_stop , y_stop ) of the desired area.
|
Function
|
line
|
Include file
|
G_WIN_R.H
|
Prototype
|
void line( GDDS *gdds_ptr ,
int x_start , int y_start , int x_stop , int y_stop )
|
Remarks
|
The function that the WIN32 api is missing :-) A simple MoveToEx( x_start ,
y_start ) and draw a LineTo( x_stop , y_stop ) in a single call.
|
Function
|
tick_x_axis
|
Include file
|
G_WIN_R.H
|
Prototype
|
void tick_x_axis( GDDS *gdds_ptr , int x_start , int y_loc ,
int tick_dir , int nolast_tick , int tick_length , int tick_interval )
|
Remarks
|
Draw a series of x axis tick marks.
|
Table of Contents
Function Index
generated on 22 September 1998 - 12:55:00
© 1998 Tierra del Fuego Ltd.
|