📄 graphics.h
字号:
void GetFillName (unsigned int fill, char &fillName[]);
/* Return name associated with the fill tag. */
unsigned int GetFill (Window w);
/* Get the fill tag associated with the window. */
void SetFill (Window w, unsigned int fill);
/* Change the window's current fill mode. The brush's color index is "frozen"
to that of the DRAWING color after this call. */
unsigned int LoadLine (char lineName[]);
/* Load a line style returning a tag referring to that line. Line style is
used for the Line void and the Polygon and Arc routines if the fill
mode is set to "skeleton".
Line Styles
"solid" normal straight line
"dashed" straight but broken line
"double" a thickened straight line
Other line styles may also be available.
*/
void GetLineName (unsigned int line, char &lineName[]);
/* Get the name of the style of the given line tag. */
unsigned int GetLine (Window w);
/* Retrieve the window's current line tag. */
void SetLine (Window w, unsigned int line);
/* Change the window's line style to a different tag. */
unsigned int GetPixelOp (Window w);
/* Return the pixel operation used to draw objects. The pixel op affects
the Pen(P) for voids Point, Line, Polygon, Arc, and the source(S)
and the Pen(P) for BitBlt.
Bitset PixelOp description
{0,1} source place new object directly on old
{0,1,2} or perform logical or with new object and old background
to produce new background
{0} and perform logical and the new object and old background
to produce new background
{1,2} Xor perform exclusive or with the new object and the old
background to produce new background
{} ~(P&D), for BitBlt it selects the pen(P)
{1} ~D
{2} ~S
{0,2} ~(PxD) or PxD for BitBlt
{3} ~(S|D)
{0,3} P|~D or P&S for BitBlt
{1,3} S&~D
{0,1,3} ~S|D
{2,3} ~P&D or P|~S|D for BitBlt
{0,2,3} Black
{1,2,3} White
{0,1,2,3} NOP
Note: the operands of the pixel operations are color tags.
There exist two basic operands source {0, 1} and destination {2, 3} the
pixel operations are formed by anding and oring these operands into
any of 16 combinations.
*/
void SetPixelOp (Window w, unsigned int op);
/* Set the pixel op using the above format. */
void Point (Window w, int x, int y);
/* Draw point at x, y coordinate. All coordinates are referenced from the
top, lefthand corner of the window. */
void Line (Window w, int x1, int y1, int x2, int y2);
/* Draw line from the point (x1, y1) to point (x2, y2). */
void Polygon (Window w, int xOffset, int yOffset, unsigned int nPoints,
Coordinate coords[]);
/* This draws a multifaced polygon. The coordinates are an array of points
stored in the Coordinate type. The first point is stored in the first
location of the array and so forth. The xOffset and yOffset tell where
to put the polygon. The coordinates stored in the arrays are referenced
from the offset point and not the window corner. The last point in the
array is considered to be connected to the first point. */
void Arc (Window w, int xCenter, int yCenter, unsigned int radius,
float startAngle, float endAngle);
/* This draws an arc. The parameters needed are the radius and the center
point. The startAngle and endAngle tell where to start and end the
arc. The angles are in degrees where zero degrees points directly right
of the center point and positive angles turn counterclockwise. If the
total angle meets or exceeds 360 degrees a full circle is drawn. */
void EnableDevice (Window w, unsigned int device);
/* Makes device active. The two devices are 0-keyboard and 1-mouse. */
void DisableDevice (Window w, unsigned int device);
/* Turn off device */
void ReadDevice (Window w, unsigned int device, WORD &input[]);
/* Requests information from a device. The input is gathered using types
in the InputType interface. For mouse events, use a Mouse struct as
the argument to "input". For keyboard input use a Keyboard struct. */
void WriteDevice (Window w, unsigned int device, char output[]);
/* Send command to device.
Keyboard Commands
"ascii" accept ascii characters
"noascii" do not accept ascii characters
"mouse" issues a mouse position event (button number of zero)
when a key is pressed even if no mouse command is set.
The mouse must be enabled. If mouse is in position mode,
these events will not be discernable from regular mouse
position events
"nomouse" keypresses will no longer generate position events
Mouse Commands
"button" accept button events
"drag" produce position events when a button is pressed
"position" produce position events at all times
"noevent" do not accept any events (button, drag, or position)
"global" make mouse position events for the entire screen.
Positions are relative to the screen
"noglobal" make mouse events occur only when mouse is over window
(this is default) positions are relative to window
*/
void Beep (Window w);
/* Make the window perform the beep signal. Audible and visible signals are
possible depending on the machine. */
void BitBlt (Window from, Window to, int sourceTop, int sourceLeft,
int destTop, int destLeft, unsigned int width, unsigned int height);
/* Reproduce the rectangle specified by sourceTop, sourceLeft, width, and
height in the window designated by from into the window, to, at the
position destTop, and destLeft. From and to may be the same window but
problems may occur if the source and destination rectangles share part
of their area. */
unsigned int DotColor (Window w, int x, int y);
/* Retreive the color tag the the pixel at x, y uses. */
void Save (Window w, ADDRESS a, long &size);
/* Copy the contents of the window into the position at the address. The
size of the resulting transfer will be returned in the parameter, size. */
void Restore (Window w, ADDRESS a, long size);
/* Copy the contents of the address into the window using size as a
guideline for how much to copy. It is vital that the window being copied
to is the same size as the original window. */
void Control(Window &w, Window ownedBy, unsigned int width, unsigned int height, char attributes[]);
/* Note: DO NOT call open first; the Control call opens "w" and associates it with ownedBy.
Text color and text background can be set by calling SetDraw/SetBackground prio to display.
For all types except "media", you must call Display to draw the control
then call GetAttributes to track it or check events.
NOTE: YOU MUST call Close for all controls before closing the ownedBy window.
Attributes are type="button" style="radio"/radioleft/check/checkleft title="NO" & before char is accelerator
scrollbar style="horizontal"/vertical range=255 (0 to) page=5 (amount +/- on page up)
edit style="single"/multiple align="center"/left/right/justify protection="read"/write scroll="up"/across/both
combobox style="drop" scroll="up" title="; separated list"
listbox style="single";title="; separated list" scroll="up"/across/both make sure box is wide enough for scroll bar
the default listbox style supports multiple selection
static title="text" draws a static edit control
groupbox title="text"
mbox style="yes" for yes/no, "ok" for ok, "cancel" for yes/no/cancel
if omitted, ok/cancel is the default
do not call Display, it is automatic
title="window caption" icon="stop" or "i" information "?" question "!" exclamation
call GetAttributes, click=1 ok, 2 cancel, 6 yes, 7 no
media style="cdaudio"/sequencer/waveaudio/waveinput/avivideo DON'T call Display
title="if not CD, path name of .mid/.wav/.avi file"
call SetAttributes op="play" to play and op="record" to record (only .wav supported)
call Getattributes to determine status or current position.
menu title="name|name|-name||name|" - means start another column; | means draw horizontal separator
GetAttributes: click=3 returns the index of the selected menu item, scroll position, or combobox selection
For popup menus, call Display once then call GetAttr repeatedly until click<>0
click=-1 indicates that a menu was clicked off without a selection
menus should be opened, displayed, and closed for each use
mmenu type is the same as menu but creates menu bar for the window
the first name is taken as the bar name; the rest form a popup menu
new items are added on the right; DO NOT call Display
In general, add a menu, and then Display the main window.
*/
typedef void *Bitmap;
void Load(Bitmap &b, char path[]);
void BGetAttributes(Bitmap b, char &out[]);
/* e.g. width=54 height=96 */
void StretchBitBlt (Bitmap from, Window to, int sourceTop, int sourceLeft,
int destTop, int destLeft, unsigned int Swidth, unsigned int Sheight,
unsigned int Dwidth, unsigned int Dheight);
/* Dwidth,Dheight=0 defaults to Sw/Sheight; Swidth,Sheight=0 defaults to the bitmap size*/
void BClose(Bitmap &b);
void WritePositionText(Window w, int top, int left, int bottom, int right,
unsigned int yOffset,
char text[], unsigned int count,
unsigned int xOffsets[],
unsigned int yOffsets[],
unsigned int fonts[]);
/* Write count chars at xOffset position; clips to rectangle.
If the first Xoffset is 65535, the offsets are ignored.
If the first Yoffset is 65535, the offsets are ignored.
If the first font is 65535, the fonts are ignored.*/
unsigned int SetNearestColor(long color);
/* Returns the tag of color closet to color; allocates a slot if one is free.
Use GetColor to find the color actually assigned. */
void UnloadFont(unsigned int font); /* Remove unneeded font */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -