Gets palette colors, line styles, and patterns.
#include <pgchart.h>
short __far _pg_getpalette( _paletteentry __far *palette );
palette | Pointer to first palette structure in array |
The _pg_getpalette function retrieves palette colors, line styles, fill patterns, and plot characters for all palettes. The pointer palette points to an array of palette structures that will contain the desired palette values.
The palette used by the presentation-graphics routines is independent of the palette used by the low-level graphics routines.
The function _pg_getpalette returns 0 if there were no errors, and it returns the value _BADSCREENMODE if current palettes have not been initialized by a previous call to _pg_setpalette.
Standards:None
16-Bit:DOS
32-Bit:None
_pg_defaultchart, _pg_initchart, _pg_resetpalette, _pg_setpalette
/* PGGPAL.C: This example illustrates presentation-graphics palettes
* and the routines that modify them, including
* _pg_getpalette _pg_resetpalette _pg_setstyleset
* _pg_getstyleset _pg_resetstyleset _pg_vlabelchart
* _pg_hlabelchart _pg_setpalette
*/
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#include <graph.h>
#include <pgchart.h>
#define TEAMS 2
#define MONTHS 3
float __far values[TEAMS][MONTHS] = { { .435, .522, .671 },
{ .533, .431, .401 } };
char __far *months[MONTHS] = { “May”, “June”, “July” };
char __far *teams[TEAMS] = { “Cubs”, “Reds” };
_fillmap fill1 = { 0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc };
_fillmap fill2 = { 0x99, 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33 };
_styleset styles;
_palettetype pal;
void main( void )
{
_chartenv env;
short mode = _VRES16COLOR;
/* Find a valid graphics mode. */
if( !_setvideomode( _MAXRESMODE ) )
exit( 1 );
_pg_initchart(); /* Initialize chart system. */
/* Modify global set of line styles used for borders, grids, and
* data connectors. Note that this change is used before
* _pg_defaultchart, which will use the style set.
*/
_pg_getstyleset( styles ); /* Get styles and modify */
styles[1] = 0x5555; /* style 1 (used for */
_pg_setstyleset( styles ); /* borders)—then set new. */
_pg_defaultchart( &env, _PG_BARCHART, _PG_PLAINBARS );
/* Modify palette for data lines, colors, fill patterns, and
* characters. Note that the line styles are set in the palette, not
* in the style set, so that only data connectors will be affected.
*/
_pg_getpalette( pal ); /* Get default palette. */
pal[1].plotchar = 16; /* Set to ASCII 16 and 17. */
pal[2].plotchar = 17;
memcpy( pal[1].fill, fill1, 8 ); /* Copy fill masks to palette. */
memcpy( pal[2].fill, fill2, 8 );
pal[1].color = 3; /* Change palette colors. */
pal[2].color = 4;
pal[1].style = 0xfcfc; /* Change palette line styles. */
pal[2].style = 0x0303;
_pg_setpalette( pal ); /* Put modified palette. */
/* Multiseries bar chart */
strcpy( env.maintitle.title, “Little League Records - Customized” );
_pg_chartms( &env, months, (float __far *)values,
TEAMS, MONTHS, MONTHS, teams );
_getch();
_clearscreen( _GCLEARSCREEN );
/* Multiseries line chart */
_pg_defaultchart( &env, _PG_LINECHART, _PG_POINTANDLINE );
strcpy( env.maintitle.title, “Little League Records - Customized” );
_pg_chartms( &env, months, (float __far *)values,
TEAMS, MONTHS, MONTHS, teams );
/* Print labels. */
_pg_hlabelchart( &env, (short)(env.chartwindow.x2 * .75),
(short)(env.chartwindow.y2 * .10),
12, “Up and up!” );
_pg_vlabelchart( &env, (short)(env.chartwindow.x2 * .75),
(short)(env.chartwindow.y2 * .45),
13, “Sliding down!” );
_getch();
_clearscreen( _GCLEARSCREEN );
_pg_resetpalette(); /* Restore default palette */
_pg_resetstyleset(); /* and style set. */
/* Multiseries bar chart */
_pg_defaultchart( &env, _PG_BARCHART, _PG_PLAINBARS );
strcpy( env.maintitle.title, “Little League Records - Default” );
_pg_chartms( &env, months, (float __far *)values,
TEAMS, MONTHS, MONTHS, teams );
_getch();
_clearscreen( _GCLEARSCREEN );
/* Multiseries line chart */
_pg_defaultchart( &env, _PG_LINECHART, _PG_POINTANDLINE );
strcpy( env.maintitle.title, “Little League Records - Default” );
_pg_chartms( &env, months, (float __far *)values,
TEAMS, MONTHS, MONTHS, teams );
_getch();
_setvideomode( _DEFAULTMODE );
exit( 0 );
}