📄 graphics.h
字号:
#pragma Graphics
#include <SYSTEM.h>
typedef void *Window;
typedef struct {
/* x, y position used in Polygon */
int x, y;
} Coordinate;
void Open (Window &w, unsigned int width, unsigned int height);
/* Create a new window. The window consists of a blank rectangle of size
width and height. The window will not be shown on the terminal until
it is displayed but all drawing operations can still be performed.
Operations that cannot be performed on an invisible window are
Disappear, and ReadDevice. */
void Close (Window &w);
/* Close deallocates the space occupied by the window and makes further
operations (except Open) on the window tag invalid. */
void Display (Window w, int leftCoord, int topCoord,
char attributes[]);
/* Make the window visible on the screen. topCoord and leftCoord indicate
where the window will be placed. The (0, 0) position is the upper,
lefthand corner of the screen. The attributes is either the title
for the window.
A title is a string of any number of characters which will be placed in
the title bar of the newly displayed window.
-1,-1 returns window to previous
position or, if a new window, lets the system pick a location.
A single character "attributes" will leave title unchanged; a
null string will clear the title.
*/
void Disappear (Window w);
/* Remove window from terminal. Note that this does not destroy the
contents of the window. */
void GetAttributes (Window w, char &attributes[]);
/* This returns a string in form described in Display for a command string.
The values of the items are the values for the actual window.
paint=0/1 indicates that the window needs repainting
title="window title" can also be used to read text from edit controls
buttonState=0(out)/1(depressed)
click=5 count of button clicks,menu item,scroll position or combobox selection since last change of state
item="0,5,6" list (in order of items selected in a list box)
arg="R/W fileName1 fileName2..." returned for a file dialog; R as 1st letter means read-only checked
*/
void SetAttributes (Window w, char attributes[]);
/* This expects a command string of the form described in the Display
void. This will only accept string in the command list form (no !>)and
not the title form. Attributes acceptable are the same as are
acceptable in Display.
brush=cardinal color index to use for the background brush
cursor="arrow/ibeam/wait/cross/uparrow/size/icon" cannot be set on controls
buttonState=0/1 forces button/check off or on
caretX=34 caretY=23 caretH=6 setting caretH to 0 hides the caret (usually before blting/repainting)
for an edit control; starthi=5 endhi=7 will highlight chars 5..6 and scroll if necessary.
starthi>endhi will turn off selection.
dialog="font/color/filein/fileout" font sets current font; color sets drawingColor;
the file dialog(supports multi-selection) takes an additional argument as follows:
arg="Dialog Box Title|Initial Directory|Initial File Name|suffix e.g. txt|Text Files(.txt)|*.txt;*.wri||
The vertical bars are required; the parts are optional.
e.g. "dialog=\"filein\" arg=\"Test|c:\\|*.*||Word(*.doc)|*.doc|Text(*.txt)|*.txt||\""
*/
void ScreenAttributes (char &attributes[]);
/* ScreenAttributes is similiar to GetAttributes but applies the terminal
screen and not to a specific window.
List of Screen Attributes
terminal="computer" name of machine or environment the terminal
is running under
buttons=numeric number of buttons on mouse
width=numeric width of the screen (in pixels)
height=numeric height of the screen (in pixels)
depth=numeric number of bits in each pixel
color=boolean TRUE if screen is a color terminal, FALSE
otherwise. (color:=(depth <> 1))
palette=0/1 if palette is present
Also will include other items that are machine specific.
*/
void GetPosition (Window w, int &topCoord, int &leftCoord);
/* Get the position of the window relative to the top, lefthand corner
of the terminal screen. */
void SetPosition (Window w, int topCoord, int leftCoord);
/* Change the position of the window. */
void GetSize (Window w, unsigned int &width, unsigned int &height);
/* Retrieve the width and height of the window in pixels. */
void SetSize (Window w, unsigned int width, unsigned int height);
/* Change the width and height of the window. If window is made smaller,
images that are covered on the right and bottom of the screen will be
erased. If the window is made larger, the area at the right and bottom
of the window will be filled with the background color. */
unsigned int OpenColor ();
/* Returns a tag that contains the value of a color to be used
on the screen. */
long GetColor (unsigned int tag);
/* Returns the color held as value of a color tag returned in OpenColor.
The format of a color is red, green, blue. The values of each
individual color ranges from 0 to 255 (8 bits each) and are stored in the
rightmost bits of the LONGINT. The colors are ordered red, green, blue
where red is higher than green which is higher than blue. The highest 8
bits are not used. Zero intensity is the lowest color intensity
thus 00000000H is black; 255 is the highest intensity thus 00FFFFFFH
is white.
00FF0000H - red
0000FF00H - green
000000FFH - blue
*/
void SetColor (unsigned int tag, long value);
/* Changes the value of a color tag. */
unsigned int GetBackgroundColor (Window w);
/* Fetch the tag used as the background color of the window. */
void SetBackgroundColor (Window w, unsigned int color);
/* Change the tag used for the background color into a new color tag. This
does not automatically convert all the pixels using the previous color
tag to the new color tag. The background color fills in behind text.*/
unsigned int GetDrawingColor (Window w);
/* Get the tag used as the drawing color of the window. The drawing color
indicates what color is used for the voids Point, Line, Arc,
and Polygon. */
void SetDrawingColor (Window w, unsigned int color);
/* Change the tag used for the drawing color. If the pen does not support
that color, it will be set to nearest color. GetDrawing/Background
ALWAYS return the physical color chosen and WILL CHANGE the color
table entry to that value. Thus, the user can determine what is actually
being drawn.*/
void ClearScreen (Window w);
/* Erase screen to the background color. */
unsigned int LoadFont (char fontName[]);
/* Retrieve font with name fontname. The cardinal returned is a tag used
to refer to that font.
r is regular, b is bold, i is italic, u underline, s strikethrough, c color in any combination.
the c option freezes the current text/background colors
Screen Fonts Courier Fonts (normal and bold)
screen.r.6 cour.r.10 cour.b.10
screen.r.7 cour.r.12 cour.b.12
screen.r.11 cour.r.14 cour.b.14
screen.r.12 cour.r.16 cour.b.16
screen.r.13 cour.r.18 cour.b.18
screen.r.14 cour.r.20 cour.b.20
screen.r.16 cour.r.22 cour.b.22
screen.b.12 (bold) cour.r.24 cour.b.24
screen.b.14
screen.b.16
more fonts are typically available on different machines.
MAX(unsigned int) is returned on error
*/
void GetFontName (unsigned int font, char &fontName[]);
/* Given a font tag this will return the text string associated with
that font. */
unsigned int GetFont (Window w);
/* Retrieve the font the window is currently using. */
void SetFont (Window w, unsigned int font);
/* Change the window's font to a new font tag. */
void GetTextExtent (unsigned int font, char text[],
unsigned int &ascent, unsigned int &descent, unsigned int &width);
/* Given a font index and a text string, determine how large the text
string is in pixels. The width is the length of the string. The
ascent and descent is the distance the top and bottom of the string
are from the baseline. Defaults to window of last operation.*/
float GetDirection (Window w);
/* Find the angular direction in degrees that the text is currently being
written at. Zero degrees is the default text angle. Positive angles
turn counterclockwise from zero degrees. */
void SetDirection (Window w, float angle);
/* Change the direction to angle. */
void WriteText (Window w, int leftCoord, int baseCoord,
char text[]);
/* Write the given text string on the window. The leftCoord and baseCoord
indicate the position the string is to placed at. The string must be
entirely printable text terminated with the null character. */
unsigned int LoadFillPattern (char fillName[]);
/* Load a fill pattern and return a cardinal tag to be used in the voids
GetFillName, GetFill, and SetFill. The fill pattern is used for the
routines Polygon, and Arc. For text, solid=fill background; skeleton mean's don't fill background
Fill Pattern
"solid" Filled will drawing color
"skeleton" Drawn with lines instead of filled(Brush set to NULL)
"left" \ diagonal call SetBackground to fill the spaces
"cross" cross hatch
"right" / diagonal
"up" |
"across" ---
"hatch" diagonal hatch
Pixel patterns (like those used for icons) may also be used as a fill
pattern.
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -