EGL - Standard basic class implementation file stdeg.inc

xiaoxiao2021-03-06  65

/ * Stdeg.inc * /

Bool checkchineseos (void) {OUTPORTB (0x03CE, 0X06); RETURN ((PEEKB (0x0040, 0x0049) == 3 && InportB (0x03cf) & 0x0f! = 0x0e)? 1: 0);}

Void initgr (void) {INT GD = VGA, GM = Vgahi; static uint hadinit = 0; if (Hadinit> 0) return; / * Prevent duplicate call initialization function * / hadinit ; if (checkchineseos ()) {Printf (" / / N Note: / //e.g. It is designed to run / / n in English in English if it is run under Chinese DOS, there may be some cases contrary to the original design ./ / n / n Press ESC to exit EG environment, other keys so strong run / / / / / / / / / / i (getKey () == ESC) exit (0);} initgraph (& gd, & gm, "); if (graphResult ()! = GROK {Printf "/ne.g. can not initializes graphics."); exit (1);} Printf ("Check Himem.sys..."); if (! xms_init ()) {closegraph (); printf ("/ nxms Device Not Installed or Not Enough Memory. "); Exit (1);} Printf (" DONE "); Printf (" / NLoad HZK16 & ASC16 TO XMS.. "); if ((xms_hzk16 = xms_malloc (270)) == Error) {end_xms (); closegraph (); Printf ("/ Nerror Alloc XMS Memory to Load HZK16); EXIT (1);} IF ((xms_asc16 = xms_malloc (5)) == error) {xms_free (XMS_HZK16); END_XMS (); Closegraph (); Printf ("/ NERROR Alloc XMS Memory to Load ASC16); EXIT (1);} if (L OAD_HZK16_2_XMS () == Error) {/ * You can not release XMS memory assigned to the font library and ASCII code, because they have released * / end_xms (); Closegraph (); Printf ("/ NERROR LOAD HZK16 OR ASC16 TO XMS. "); exit (1);} Printf (" DONE "); Printf (" / nCheck mouse.... "); reset_mouse (); if (! mouse_there) {xms_free (xms_hzk16); xms_free XMS_ASC16); End_XMS (); Closegraph (); Printf ("/ NMouse Not Installed."); exit (1);} mouse_off (); Printf ("DONE"); Printf ("/ NEASY Graphics Initializes OK!") Mouse_on (); installevent (); infertimer ();

Atexit (closegr); / * Register exit function, when the EXIT is accidentally adjusted, the system does not collapse * /} void closegr (void) {static uint hadclose = 0; if (Hadclose> 0) return; / * Prevent repetitive calls Exit function * / hadClose ; endtimer (); set_event_handler (0, 0); xms_free (xms_hzk16); xms_free (xms_asc16); end_xms (); closegraph () ();

Bool Inbar (int X, int y, int b) {return ((x> = L && x <= R && y> = t && y <= b)? 1: 0) }

Int Max (int A, int b) {return (a> = b? a: b);}

Void Fillbar (Int L, INT T, INT R, INT B, INT Style, INT BKGROUND) {structure FillSettingStype F; GetFillSettings (& f); setfillstyle (style, bkground); mouse_off (); bar (l, t, r, b); mouse_on (); setfillstyle (f.pattern, f.color);

Bool Winmake (int L, int 4, int stat, int bc, int frame, int stat, {INT I, FRAME_THICK, Color1, Color2; if (frame == null_frame) Return (OK); Switch (Frame) {CASE STD_FRAME: / * Similar to the Border of Win95 * / frame_thick = 2; Break; Case Button_Frame: / * Border width only 1 * / frame_thick = 1; Break; Case Shadowline_Frame: / * Border with yang line * / Fillbar (L, T, R, B, Solid_Fill, BC); mouse_off (); setColor (15); line (L, T, R, T); LINE (L, T, L, B); SetColor (8 ); Line (R, T, R, B); LINE (L, B, R, B); SetColor (8); for (i = 0; i <2; i ) {line (L 4 i, T 4 I, R-3-I, T 4 I); / * UP - * / LINE (L 4 I, T 4 I, L 4 I, B-4-I ); / * left | * / line (L 4 I, B-5 ​​ I, R-5 I, B-5 ​​ I); / * bottom - * / line (R-5 I, T 6-i, R-5 I, B-5 ​​ I); / * Right | * / setColor (15);} mouse_on (); return (ok); default: / * such as non-above, Frame Parameter as the width of the border * / frame_thick = frame;} / * switch end * / color1 = (status == button_up)? 15: 8; color2 = (status == Button_UP)? 8: 15; Fillbar (L 1, T 1, R-1, B-1, Solid_Fill, BC); mouse_off (); for (i = 0; i

/ * Direct Write Screen & XMS Database Read Technical Display Strings * / Void Outtext (INT X, INT Y, Unsigned Char Color, Unsigned Char * Hz) {Long i; Char Far * Ptr; Short Movebit, Ybit; Struct XMS_MOVE Block; struct viewporttype v; ubyte by2, byte1, byte2, bm; getViewsettings (& V); x = v.Left; y = v.top; / * Considering it is possible to set a non-full Screen view * / if (x <0 || y <0 || x> = 639 || y> = 479 || x> = v.right || y> = v.bottom) Return; Ybit = Y 15> = V.BOTTOM? V.BOTTOM-Y: 16; / * Make Y coordinates no more than the next boundary * / ybit = ybit <= 0? 0: ybit; / * Using write mode 2 * / OUTPORTB (0x3CE , 5); OUTPORTB (0x3cf, 2); / * Write 4 bit flat * / OUTPORTB (0x3c4, 2); OUTPORTB (0x3c5, 255); OUTPORTB (0x3CE, 8); While (* hz) {byte1 = (Ubyte) * hz; byte2 = (ubyte) * (Hz 1); if ((Byte1> = 0xa1 && Byte1 <= 0xfe) && (byte2> = 0xa1 && Byte2 <= 0xfe)) {ubyte * byptr = by ; If (x 15> v.right) Break; / * Beyond the view is not displayed * / i = (Byte1-0xA1) * 94 byte2-0xa1; i << = 5; block.destination_handle = 0; / * Put the Chinese character inserted data from the expansion to the array * / block.source_handle = xms_hzk16; block.destination_offset = (long) mk_fp (_ds, by); / * _ _ DS is used in small mode * / block.source_offset = i; block.byte_count = 32; xms_movedata (& block); / * Because one byte contains 8 image points, you must consider that the starting position is not in x% 8 == 0 At the time of the case * / / * Set a offset movit * / movebit = x% 8 written only from a valid X position; / * Relative offset in the buffer in the buffer * / for (i = 0; i > Movebit; bm = * ptr; * PTR

= Color; / * Write color value to buffer * / / * the second byte * / outportb (0x3cf, (by1 << (8-mov)) | (BY2 >> Movebit)); / * To write 8 Mask, second byte * / bm = * ptr; * PTR = color; / * the third byte, if Movebit == 0 NOT WRITE * / IF (Movebit! = 0) {/ * To write 8 shirts * / outputb (0x3cf, BY2 << (8-mov)); bm = * ptr; * Ptr = color;}} / * Show Chinese character end * / x = 16; hz = 2; } Else {if (x 7> v.right) Break; / * Beyond the view, no display * / block.destination_handle = 0; / * Displace the Chinese character data from the expansion to the array * / block.source_handle = xms_asc16; block.destination_offset = (long) mk_fp (_ds, by); / * _ds for small mode * / block.source_offset = byte1 * 16; block_movedata (& block); Movebit = x% 8 ; / * Start location relative displacement * / for (i = 0; i > Movebit); BM = * PTR; * PTR = color; if (movebit! = 0) {OUTPORTB (0x3cf, BY1 << (8-Movebit); BM = * PTR; * PTR = color;}} / * for end * / x = 8; Hz ;} / * if ASCII end * /} / * wh Ile end * / bm = bm; outputb (0x3CE, 8); OUTPORTB (0x3cf, 255); / * 8 bits of each byte in the buffer * / OUTPORTB (0x3CE, 5); OUTPORTB (0x3cf, 0);

BOOL LOAD_HZK16_2_XMS () {file * fp, * fp1; / * Load HZK16 into the expansion memory, need a handle that has been allocated enough * / struct Sregs Sregs; struct XMS_MOVE BLOCK; long string_length; long char_count = 0L; IF (((( FP = FOPEN ("HZK16", "RB")) == NULL) RETURN (ERROR); IF ((fp1 = fopen ("ASC16", "RB")) == null) {fclose (fp); Return ( Error);} while ((String_Length = FREAD (XMS_2_BASEMEM_BUFFER, 1, XMS_BUF, FP))! = 0) {block.byte_count = string_length; / * The number of bytes actually read * / block.source_handle = 0; block. source_offset = (long) MK_FP (_DS, xms_2_basemem_buffer); block.destination_handle = xms_hzk16; / * xms memory handle * / block.destination_offset = char_count; / * offset in the expansion memory * / char_count = string_length; / * Fixed Offset * / if (xms_movedata (& block) == error) {fclose (fp); xms_free (xms_hzk16); return (error);}} / * while end * / fclose (fp); while (String_length = FREAD) (XMS_2_BASEM_BUFFER, 1, XMS_BUF, FP1))! = 0) {block.byte_count = 4096; / * Really read the number of bytes * / block.source_handle = 0; block.source_offset = (long) m K_FP (_ds, xms_2_basemem_buffer; block.destination_handle = xms_asc16; / * xms memory handle * / block.destination_offset = 0; / * Offset * / if (xms_movedata (& block) == error in the expansion memory * / if (xms_movedata (& block) == error) {fclose (fp1); xms_free (xms_asc16); return (error);}} / * while end * / fclose (fp1); return (ok);}

Bool Backupwin (int L, Int T, Int R, Int B, INT * block, int imageblock []); BOOL Backupwin (int L, Int T, Int R, Int B, int * block, int imageblock []) / * Parameters: Boundary and block the number of blocks of blocks blocks, * ImageBlock is a variable address that is wanting to get an XMS memory / screen data handle * / {struct xms_move xms_block; int i, block_num, high, block_high; / * HIGH Each Partition block Height * / long total_size, block_size [xms_block_num]; int Handle; / * A temporary handle * / high = bt; total_size = imagesize (L, T, R, B); / * Because ImageSize () cannot be calculated 64K bitmap, here the principle of this function is calculated * / if (Total_Size> 65534) Total_size = (long) ((float) (RL) * HIGH / 2.0 41); for (i = 1; i <= XMS_BLOCK_NUM; I ) ife (FLOAT) Total_Size / (FLOAT) i

Bool Restorewin (int L, Int T, Int R, Int B, int block, int imageblock []); Bool Restorewin (int L, Int T, int R, int b, int block, int imageblock []) / * parameter : Boundary and the number of blocks brought into interface block, * imageblock is the variable address of the XMS memory / screen data handle wants to get an XMS memory / screen data handle * / {struct XMS_MOVE XMS_BLOCK; INT I, HIGH, Block_High; / * High Each division * / Long block_size [xms_block_num]; high = bt; r = r; for (i = 0, block_high = high / block; i

/ * ... menu function to the return value: When you receive menu_close, turn it off, check back to OK; * // * Continu when you receive menu_net_close, close yourself, close yourself, close * // * menu_close_all * // * ... menu function: Return OK (when normal end), menu_close_all (when all menu is required to close * // * ... call menu function: When the menu returns OK, it is determined by it Close No, return MENU_CLOSE * / / * or MENU_NOT_CLOSE; return MENU_CLOSE_all, it also returns MENU_CLOSE_ALL * / INT POPMENU (Struct CMenu (* m)) {int how_to_do, mx, my, redraw = 1; int Oldchoice, Newchoice, Left, Top, Right, Bottom; Int Width = 0, I, N, Y; ClearKeyBuffer (); if ((* m) .frame == Null_Frame) Redraw = 0; / * this is for null_frame * / For (i = 0, n = 0; i 639 || ((* m) .top (n 1) * 16)> 479) {systemror.Str1 = "[PopMenu] The menu coordinate is not legal "; systemerror.str2 =" coordinates should be in the screen range "; MessageBox (& SystemError); Return (E Rror);} IF (LEFT-6, TOP-8, Right 6, Bottom 8, & (* m) .BackimageBlockNum, (* m) .savebackImage) == error) {systemRr1 = "[ PopMenu] Non-sufficient memory creation menu, if you frequently appear frequently; systemror.Str2 = ", please contact Wang Jiabao."; MessageBox (& system); return (error);} Winmake (LEFT-6, TOP-8 , Right 6, Bottom 8, Menu_Background, (* m) .frame, Button_UP); mouse_off (); for (i = 0, y = top; i

SetColor (WHITE); LINE (Left 8, Y 9, Right-8, Y 9); Continue;} / * draw a line end * / outtext (left, y, menu_text_color, (* m) .inf [ I] .info;} / * for end * / mouse_on (); if (redraw) {Fillbar (Left, Top, Right, Top 16, Solid_Fill, Menu_choice_Background); mouse_off (); Outtext (Left, Top, Menu_choice_TEXT_COLOR (* m) .inf [0] .info; mouse_on ();} else {mouse_off (); outtext (left, top, menu_choice_text_color, (* m) .inf [0] .info); mouse_on (); } Oldchoice = Newchoice = 0; A: for (;;) {if (mouse_moved) {mouse_moved = 0; MX = Cmx; My = CMY; IF (MX> Left && MX Top && my

8, (* m)., / (* M) .savebackImage); return (ok);} if (lbutton_down) {/ * If the left mock button calls the function in the menu * / lbutton_down = 0; MX = Cmx; My = CMY; IF (INBAR (MX, MX, MX, MX, MX, Right, Bottom-1)) {IF ((* m) .inf [(my-top) / 16] .info [0]! = '-') {if (redraw) {Fillbar (Left, Oldchoice * 16 TOP, Right, Oldchoice * 16 TOP 16, SOLID_FILL, MENU_BACKGROUND); mouse_off (); Outtext (Left, Oldchoice * 16 TOP, Menu_text_color, (* m) .inf [ildchoice] .info; mouse_on ();} else {mouse_off (); OutText (Left, Oldchoice * 16 Top, menu_text_color, (* m) .inf [ilchchoice] .info) Mouse_on ();} Oldchoice = (My-TOP) / 16; if (redraw) {Fillbar (Left, Oldchoice * 16 TOP, Right, Oldchoice * 16 TOP 16, Solid_Fill, Menu_choice_Background; mouse_off (); OutText (left, oldchoice * 16 top, MENU_CHOICE_TEXT_COLOR, (* m) .inf [oldchoice] .info); mouse_on ();} else {mouse_off (); OutText (left, oldchoice * 16 top, MENU_CHOICE_TEXT_COLOR, (* m) .inf [ilchchoice] .info; mouse_on ();} keynter: how_to_do = (* (* m) .inf [oldchoice] .function) (); Switch (How_to_do) {CASE MENU_CLOSE: EXIT: RESTOREWIN (Left-6, TOP-8, Right 6, Bottom 8, (* m) .BackImageBlocknum, / (* m) .savebackImage); Return (OK); Case Menu_not_close: mouse_moved = 1; lbutton_down = 0; how_to_do = menu_not_close; / * is indicated to keep open status * / goto a; case menu_close_all: Restorewin (Left-6, TOP-8, Right 6, Bottom 8, (* m ). Backimageblocknum, / (* m). SaveBackImage); lbutton_down = 0; return (menu_close_all); default: / * pehpers the function is null () * / how_to_do = menu_not_close; Continue;

} / * Switch end * /} / * if lbutton in menu end * /} else {/ * Press LButton out of menu coords, Close the menu * / restorewin (Left-6, TOP-8, Right 6, Bottom 8, (* m) .ssavebacknum, / (* m) .savebackImage); return (ok);}} / * if button Down end * / if (kbhit ()) {Int kbcode; if ((kbcode = getKey) )) == Enter) goto keyenter; if (kbcode == esc) goto exit;}} / * for end * /} / * function end * / bool initdialog (struct cdialog * bm) {Int l, t, r, B, I; / * the frame coords of menu * / if ((* bm) .left <0 || (* bm) .top <0 || (* bm) .right> 639 || (* BM). Bottom> 479) {systemError.Str1 = "[Initdialog] dialog box coordinate is not legal"; systemError.Str2 = "The coordinates should be in the screen range"; MessageBox (& SystemError); return (Error);} l = (* BM) .left; t = (* bm) .top; r = (* bm) .right; b = (* bm) .bottom; if (rl> = 639 && bt> = 479) (* bm) .MOVE = 0; IF (backupwin (l, t, r, b, & (* bm). Backimageblocknum, (* bm) .savedialogback) == error) {systemerror.str1 = "[initdialog] Non-enough memory creation dialog If you often appear frequently "; systemerror.str2 =", please contact Wang Jiabao. "; MessageBox (& System); Return (Error);} Winmake (L, T, R, B, Menu_Background, std_frame, button_up) Fillbar (L 4, T 4, R-4, T 20, Solid_Fill, LightBlue); SetViewPort (L 4, 0, R - ((* bm) .close? 20: 4), 479, 1 ); Mouse_off (); outtext (0, (* bm) .top 5, White, (* BM) .title; / * Write title * / mouse_on (); setviewport (0,0,639,479,1); if ( (* bm) .close) / * Judgment Whether the shutdown button * / button is displayed ((* bm) .right-20, (* bm) .top 4, null, "x", button_up); (* bm). Active = 1; / * Applied to the Mode dialog * / (* (* bm) .draw) (* bm); / * can initialize the client area * /}

Int rundialog (struct cdialog * bm) {Int x, y, distx, disty, mx, my; int it, ot, o ot, OB, NL, NT, NR, NB; INT ONCE_IN_TILE = 0, RETURN_VALUE = Dialog_Close; IF ( ! (* bm) .active) Return (OK); NL = OL = (* bm) .left; NT = OT = (* bm) .top; nr = or = (* bm) .right; nb = ob = Ob = (* bm) .bottom; While (1) {if (lbutton_down) {

MX = cmx; my = cmy; IF (inbar (mx, my, (* bm) .right-20, (* bm) .top 4, (* bm) .right-4, / / ​​* If you press Button * / (* bm) .top 20) && (* bm) .close) {ix (ActionButton ((* bm) .right-20, (* bm) .top 4, null, "x") = CONTINUE; EXIT: RESTOREWIN (OL, OT, OR, OB, (* BM)., (* Bm) .savedialogback; (* bm) .active = 0; reset_event_status (); clearKeyBuffer (); Return (RETURN_VALUE);} / * if pressed x Button end * / if (Inbar (MX, MX, MY, (* BM) .left 4, (* bm) .top 4, (* bm) .right - (* BM) .Close? 20: 4), (* bm) .top 20) && / (* bm) .move) {/ * in the title area * / DISTX = MX - (* bm) .left; disty = MY - (* bm) .top; / * Set Mouse maximum mobile zone * / set_mousex (DISTX, 639- (* bm) .right - (* bm) .left-distx)); set_mousey (DISTY, 479- (* bm) .bottom - (* bm) .top-disty)); setWriteMode; setColor (8); setLinesTyle (0, 0, 3); mouse_off (); Rectangle (NL 1, NT 1 , NR-1, NB-1); mouse_on (); while (! lbutton_up) {if (mouse_moved) {mouse_moved = 0; x = cmx; y = cmy; mouse_off (); Rectangle (NL 1, NT 1 NR -1, NB-1); NL = X-Distx; NT = Y-DITY; NR = X-DISTX (* BM) .right - (* bm) .left; nb = y-disty (* bm) .bottom - (* bm) .top; Rectangle (NL 1, NT 1, NR-1, NB-1); mouse_on (); ONCE_IN_TIL = 1;} / * if MOSUE_MOVED END * /} / * while lbutton_down Title Bar END * / SET_MOUSEX (1,639); set_mousey (1,479); if (onCE_IN_TITLE) {mouse_off (); Rectangle (NL 1, NT 1, NR-1, NB-1); mouse_on ();} setLinesTyle (0, 0, 1); if (lbutton_up) {/ * releases the left button to end movement, move the frame to the new zone * / reset_event_status (); if (ot == nt && == nl) {/ * if new Positon ==

Old Position Do Nothing * /} el, OT, OR, OB, & (* BM) .BackImageBlockNum, (* BM). SavedialogImage); Restorewin (OL, OT, OR, OB, (* BM). BackimageBlockNum, (* bm) .savedialogback; Backupwin (NL, NT, NR, NB, & (* BM) .BackimageBlockNum, (* bm) .savedialogback; Restorewin (NL, NT, NR, NB, (* BM) . Backimageblocknum, (* bm) .savedialogimage); OL = NL; OT = nt; = nr; ob = Nb;} (* bm) .left =} (* bm) .top = OT; / * Save new Coordinate * / (* bm) .right = OR; (* bm) .bottom = OB; setLinesTyle (0, 0, 1); setwritemode (copy_put);} Continue;} / * if pressed title bar end * / setwritemode Copy_put); setLinesTyle (0, 0, 1); ClearKeyBuffer (); if (INBAR (MX, MX, MY, (* BM) .left 2, (* bm) .top 22, (* bm) .right-2 (* bm) .bottom-2))))))))) IF (* (* bm) .react) (MX, MX, MY, * BM, & RETURN_VALUE) == Dialog_close) goto exit; / * If the left button is in the box, Call response function * / lbutton_down = 0; Continue;} / * if lbutton_down end * / if (kBhit ()) {mx = my = -1; if (* (* bm) .react) (MX, MX, MY) * bm), & retURN_VALUE) == Dialog_close) goto exit; clearKeyBuffer (); CO Ntinue;}} / * while end * /} / * function end * /

Bool Button (int GL, INT GT, CHAR * BTN_STR, CHAR * STYLE, INT Status {char Kind, * p, * str [] = {"confirm", "cancel", "start"}; int Width, Height, GR, GB, I, X, Y, Which_arrow, addbits; static int arrow [] [8] = {0x10, 0x38, 0x7c, 0x1, 0x38, 0x38, 0x38, 0x00, 0x00, 0x38, 0x38, 0x38, 0xfe, 0x7c, 0x38, 0x10}; / * arrow array 0 is up, 1 is down * / IF (GL <0 || GT <0) Return (Error); Switch ((Kind = Toupper (Style [STYLE 0])) {case 'x': / * EXIT BTN * / CASE 'U': width = x_btn_w; height = x_btn_h; / * UP arrow btn * / which_arrow = 0; Break; Case 'D': width = X_BTN_W; Height = X_BTN_H; / * Down Arrow BTN * / Which_arrow = 1; Break; Case 'C': / * Check * / Case 'R': Width = CBTN_W; Height = CBTN_H; / * Radio * / P = Null Break; Case 'Y': width = NORMAL_BTN_W; Height = Normal_BTN_H; / * YES BTN * / P = STR [0]; Break; Case 'N': width = NORMAL_BTN_W; Height = NORMAL_BTN_H; / * NO BTN * / P = STR [1]; Break; Case 's': width = 100; Height = 23; / * START BTN * / P = STR [2]; Break; Default: width = NORMAL_BTN_W; Height = NORMAL_BTN_H; P = BTN_STR;} GR = GL Width; GB = GT Height; WinMake (GL 1, GT 1, GR-1, GB-1, 7, Button_Frame, Status); IF Kind == 'u' || Kind == 'D') {/ * Pictorial Arrow * / if (status == Button_UP) Addbits = 0; Else AddBits = 1; / * Make it inward * / mouse_off ); For (y = 0; y <8; y ) for (x = 0; x <8; x ) IF ((arrow [which_arrow] [y] >> (7-x)) & 1) PUTPIEL (GL 5 X AddBits, GT 5 Y, Black); mouse_on ();

Return (OK);} / * if 'u' || 'd' end * / if (kind == 'x') {/ * painting close button * / if (status == button_up) addbits = 0; Else AddBits = 1; / * Make it inward * / mouse_off (); for (i = 0; i <2; i ) {setColor (0); line (GL 4 AddBits, GT 4 I, GR -4 AddBits, GB-4 I); / * / * / line (GR-4 AddBits, GT 4 I, GL 4 AddBits, GB-4 I); / * / * /} Mouse_on (); RETURN (OK);} / * if end * / i = GL (int) (Width / 2.0- (Strlen / 2.0) * 8); mouse_off (); setColor (Black); / * Add a box * / Rectangle (GL, GT, GR, GB); OUTTEXT (i (status == Button_UP? 0: 1), GT 5, Style [1] == 0? Btn_text_color: 8, p) Mouse_on (); return (OK);} BOOL ActionButton (int L, INT T, CHAR * BTN_STR, CHAR * STYLE) {Int Width, Height, R, B, X, Y; IF (lbutton_down) lbutton_up = 0; Button (L, T, BTN_STR, STYLE,!! Button_UP); Switch (Toupper (style [0])) {case 's': width = 100; height = 23; / * start btn * / break; casser 'x' : / * EXIT BTN * / CASE 'U': / * Up arrow btn * / case 'd': width = x_btn_w; height = x_btn_h; / * DO Wn arrow btn * / break; case 'c': / * check * / case 'r': width = CBTN_W; Height = CBTN_H; / * Radio * / BREAK; CASE 'Y': / * yes btn * / case ' N ': / * no btn * / default: width = NORMAL_BTN_W; Height = NORMAL_BTN_H;} r = L width; b = t height; while (! Lbutton_up); lbutton_up = 0; x = cmx; y = cmy Button (L, T, BTN_STR, STYLE, Button_UP); RETURN (INBAR (X, Y, L, T, R, B));

int MessageBox (struct CMessageBox * w) {int x, y, which, i, return_value, x_width, y_width, max_str; char whichchar; struct CDialog bm; x_width = (NORMAL_BTN_W 6) * (* w) .style 16; y_Width = NORMAL_BTN_H 76; MAX_STR = Max (Strlen (* W) .STR1), Strlen (* w) .STR2)); X_Width = max (x_width, max_str * 8 8); if (x_width> 639) ; Bm.title = (* w) .title; msg_btn_num = (* w) .style; bm.left = 319-x_width / 2; bm.top = 239-y_width / 2; bm.right = 319 x_width / 2 ;; bm.bottom = 239 y_Width / 2; bm.close = (* w) .close; bm.move = (* w) .move; msgbox_str1 = (* w) .str1; msgbox_str2 = (* w). Str2; bm.draw = gmessageboxdraw; bm.react = gmessageboxreact; for (i = msg_btn_num; i> 0; i -) {msg_btn [msg_btn_num-i] [0] = 2 (normal_btn_w 6) * i; msg_btn [MSG_BTN_NUM-I] [1] = 6 NORMAL_BTN_H;} IF (INTDIALOG (& BM) == Error) Return (Error); Rundialog (& BM));} static int GMessageBoxDraw (struct cdialog bm) {INT i; Char * which_btn [] = {"y", "n"}; setviewport (bm.left, bm.top 22, bm.right, bm.bottom, 1); mouse_off (); outtext (6, 6, menu_t) EXT_COLOR, MSGBOX_STR1); OUTTEXT (6, 26, menu_text_color, msgbox_str2); mouse_on (); setViewPort (0, 0, 639, 479, 1); for (i = 0; i 0) / * Conditions display 2 buttons, order Y, n * / button (bm.right-msg_btn [i] [0], bm.bottom-msg_btn [i] [1], null, which_btn [i] , Button_up);

int gMessageBoxReact (int x, int y, struct CDialog bm, int * return_value) {/ * the funcion return whether Dialog close, return_value tell RunDialog the function what had done * / int which, tmp_btn [2] [2], pressed = 0, Key; Char * Whichchar [] = {"y", "n"}; for (which = 0; Which

Void Initbtn (int Group, Struct Cbutton BTN [], Struct CDialog BM) {INT I, J, L, T; Groups = Group; Mouse_off (); for (i = 0; i

INT BTNREACT (INT X, INT Y, STRUCT CBUTTON BTN [], Struct Cdialog BM) {INT I, J, K, L, T; For (i = 0; i

INT GEDITFIELD (Int L, Int T, int R, Int B, INT N, STRUCT CEDIT G [], INT YES_X, / INT YES_Y, INT NO_X, INT NO_Y, CHAR * TITLE / * N IS HOWMANY Edit Filed, THE Edit Not Have Date Type * // * ONLY RETURN 0 OR 1, 0 IS YES, 1 IS NO * / {INT I, J, X, Y, LD, C, P, Show = 1, MX, MY, COUNT Struct CDialog BM; ClearKeyBuffer (); if (l <0 || T <0 || R> 639 || B> 479) {systemror.str1 = "[geditfield] function editfield error, boundary superior; systemerror.STR1 = NULL; MessageBox (& System); return (error);} Oldx = -8; Oldy = -8; bm.title = title; bm.left = L; bm.top = T; bm.right = r; BM. Bottom = B; bm.close = 0; bm.move = 0; bm.draw = null; bm.react = null; if (Initdialog (& BM) == Error) Return (Error); / * Initialization box * / if (YES_X> = 0) Button (L YES_X, T 22 YES_Y, NULL, "Y", Button_UP); if (NO_X> = 0) Button (L NO_X, T 22 NO_Y, NULL, "N ", Button_up); for (i = 0; i

YES_Y, L YES_X NORMAL_BTN_W, T 22 YES_Y NORMAL_BTN_H)) {IF (ActionButton (L YES_X, T 22 YES_Y, NULL, "Y") == 0) Continue; ExitEdit: Restorewin (L, T, R, B 1, BM.BackimageBlocknum, Bm.Savedialogback; ReleaseTimer (CURS_TIME); RETURN (0);} if (INBAR (MX, MX, MY, L NO_X, T 22 NO_Y, L NO_X NORMAL_BTN_W, T 22 NO_Y NORMAL_BTN_H)) {IF (ActionButton (L NO_X, T 22 NO_Y, NULL, "N") == 0) Continue; Restorewin (L, T, R, B 1, BM.BACKIMAGEBLOCKNUM, BM.SAVEDIALOGBACK; ReleaseTimer (CURS_TIME); RETURN (1);} for (count = 0; count 0) I -; p = 0; Break; Case Down: IF (i 0) P -; Break; Case Right: IF (P

) G [i] .E [p-1] = ''; / * in the '' = space * / else {memmove (& g [i] .e [p-1], & g [i] .e [p ], g [i] .wp); g [i] .E [g [i] .w-1] = '/ 0';} / * int the '_' * / winmake (L G [i] .ex-1, t 22 g [i] .e-2, l g [i] .Ex 1 g [i] .w * 8, t 22 g [i] .ey 18 , G_edit_fill_color, / button_frame,! Button_up); mouse_off (); OUTTEXT (L G [i] .ex, T 22 G [i] .ey-2, g [i] .color, g [i]. e); mouse_on (); p -; break; case del: IF (TouPper (g [i] .p [0]) == 'n' &&g [i] .e [p] == '.' Break; IF (g [i] .w == 1) g [i] .e [0] = null; else {ix (TouPper (g [i] .p [0] == 'n')) g [i] .e [p] = '; else {memmove (& g [i] .e [p], & g [i] .e [p 1], g [i] .wp); g [i] .e [g [i] .w-1] = null; / * in the '_' * /}} Winmake (L G [i] .ex-1, t 22 g [i] .ey- 2, L G [I] .Ex 1 g [i] .w * 8, t 22 g [i] .e 18, g_edit_fill_color, / button_frame,! Button_up); mouse_off (); OutText L g [i] .ex, t 22 g [i] .ey-2, g [i] .color, g [i] .e); mouse_on (); break; case esc: case pgup: case PGDN: Case Tab: Continue; Default: Switch (To Upper (g [i] .p [0])) {/ * the @switch * / case 'c': Switch (TouPper (g [i] .p [1])) {case 'n': if (! Isdigit (c)) Continue; Break; Case 'A': IF (! isalpha (c)) Continue; Break; Case 'B': IF (! IsalNum (c)) Continue; Break;} Break;} / * the @switch end * / if (p

g [i] .e [p], g [i] .wp-1); Break;}} g [i] .e [p] = C; WinMake (L G [i] .ex-1, t 22 g [i] .e-2, l g [i] .ex 1 g [i] .w * 8, t 22 g [i] .e 18, g_edit_fill_color, / button_frame, Button_up); mouse_off (); Outtext (L G [i] .ex, T 22 g [i] .e-2, g [i] .color, g [i] .e); mouse_on () ; P ;} / * if (p

INT SELECT (int WL, int WT, INT WR, INT WB, CHAR * STR []) / * The coordinates of the window are graphical, where the coordinates involving the actual mapping function are graphical, otherwise the text coordinates, windows The coordinates must be 16 times, calling methods: char * STR [] = {"123", ..., "dataend122", "null"}; arrays must "null" is the the end flag of select with NULL end "null" is the end flag of select ( The last * STR passing to this function is "NULL", IT A String, Not A '/ 0' * / {INT i, N, HScroll_Height, HScroll_Start; Int w_old_ligter = 0, w_ligter = 0 , w_height, str_end = -1, str_old_option = 0, STR_OPTION = 0; / * Old highlight T, this is the highlighted T, window height T, word tail, will be erased, the current option, current Selected * / INT NEED_DRAW = 1, MUST_REDRAW = 0, Key, Double_Press = 0; / * Whether to override Win * / CHAR TMP [80]; IF ((WR-WL) / 16 <2 || (WB- WT) / 16 <3 || (WR-WL)% 16 || (WB-WT)% 16 || WL <0 || WT <0 || WR> 639 || WB> 479 || WL> = WR || WT> = WB) {systemror.str1 = "[select] List Select the coordinate of the function"; systemerror.str2 = "wide and high should be 16 times, and the coordinates should not be exceeded"; MessageBox (& SystemEmerror) ); Return (Noselect);} while (STRCMP (STRUPR (STRCPY (TMP, STR_ STR_END])), "null")! = 0); if (str_end == 0) Return (NOSTRING); / * No string can be select * / w_HEight = (WB-WT) / 16; / * Calculation window height * / Winmake (WR-14, WT 16, WR, WB-16, 7, Button_Frame, Button_u P); Button (WR-15, WT, NULL, "U", Button_UP); Button (WR-15, WB-16, NULL, "D", Button_UP); WR- = 16; / * Left the scroll bar Space * / Fillbar (WL, WT, WR, WB, Solid_Fill, Menu_Background; for (;;) {if (Need_DRAW) {/ * If the window does not need to be heavy, it is slightly, increase the speed, prevent flashing * / for ( i = 0, n = str_option-w_ligter; i

STR_END && N> = 0) {/ * Processing the last option is not in the window at the bottom of the window * / if (i> = str_end) Break; setViewPort (WL, WT, WR, WB, 1); mouse_off (); OutText 0, i * 16, menu_text_color, str [n]); mouse_on ();}} / * if End * / else {/ * window does not have to scroll, just let the bright strips can be updated, update the old bright strip options * / Fillbar (WL, WT W_OLD_LIGTER * 16, WR, WT (W_OLD_LIGTER 1) * 16, Solid_Fill, Menu_Background; setViewPort (WL, WT, WR, WB, 1); mouse_off (); Outtext (0, w_old_ligter * 16, menu_text_color, str [str_old_option]); mouse_on ();} / * else end * /} / * for end * / setviewport (0, 0, 639, 479, 1); / * Heavy painting is being selected by bright strips * / Fillbar (WL, WT W_LIGTER * 16, WR, WT 1) * 16, Solid_Fill, Menu_choice_BACKGROUND); SetViewPort (WL, WT, WR, WB, 1); MOUSE_OFF (); Outtext (0, W_Ligter * 16 , Menu_choice_text_color, str [str_option]); mouse_on (); / * Update display progress bar * / setViewPort (0, 0, 639, 479, 1); if (str_end> w_height) {HScroll_Height = (int) ((float) (WB-WT) -32) / (float) W_HEight); hscroll_start = (int) (wb-hscroll_height-wt-32) / (float) (STR_END-1) * (FLO AT); Fillbar (WR 1, WT 16, WR 16, WT 16 HScroll_start, Solid_Fill, 7); Fillbar (WR 1, WT 16 HScroll_Height HScroll_start, WR 16, WB- 16, Solid_Fill, 7); WinMake (WR 2, WT 16 HScroll_Start, WR 16, WT 16 HScroll_Start HScroll_Heart, 7, Button_Frame, Button_up);} / * if end * /} / * if end * / If (double_press); need_draw = 0; if (lbutton_down) {INT TMPX, TMPY; TMPX = CMX; TMPY = CMY; IF (INBAR (TMPX, TMPY, WL 1, WT 1, WR) -1, wb-1)) {INT PRESS_POSTION = (TMPY-WT) / 16; IF (STR_OPTION PRESS_POSTION-W_LIGTER> STR_END-1) {lbutton_down = 0;

/ * Here is where> maxstrings, no react * / continue;} w_old_ligter = w_ligter; str_old_option = str_option; w_ligter = press_postion; str_option = press_postion-w_old_ligter; need_draw = 1; if (get_double_press ()) double_press = 1; LBUTTON_DOWN = 0 Continue;} / * Press in test window end * / if (Inbar (TMPX, TMPY, WR 1, WT 1, WR 15, WT 15)) {if (! ActionButton (WR 1, WT, NULL, "U")) Continue; NEED_DRAW = 1; Key = Up; Reset_Event_Status (); goto mouse_operation;} if (inbar (TMPX, TMPY, WR 1, WT 17, WR 15, WT 17 HScroll_Start )) {NEED_DRAW = 1; key = pgup; reset_event_status (); goto mouse_operation;} = f (inbar (TMPX, TMPY, WR 1, WT 17 HSCROLL_HEIGHT HSCROLL_START, WR 15, WB-17)) {NEED_DRAW = 1; key = pgdn; reset_event_status (); goto mouse_operation;} = f (inbar (TMPX, TMPY, WR 1, WB-15, WR 15, WB-1)) {if (! ActionButton (WR 1, WB-16, NULL, "D")))) Continue; NEED_DRAW = 1; Key = Down; Reset_Event_Status (); goto mouse_operation;} lbutton_down = 0;} / * lbtn_down end * / if (kbhit ()) { NEED_DRAW = 1; key = getKey (); mouse_operation: switch (key) {copy up: if (str_end> 0) {if (str_option == 0) {NEED_DRAW = 0; Break;} if (w_ligter> = 0) { / * If the bright strip does not reach the upper boundary * / w_old_ligter = w_ligter; if (w_ligter> 0) w_ligter ---; str_old_option = str_option--; Break;}} / * if str_end> 0 end * / break; Case Down: IF (STR_END> 0) {if (str_option == STR_END-1) {NEED_DRAW = 0; Break;} if (w_ligter <= w_height-1) {w_old_ligter = w_ligter; if (w_ligter <

w_height-1) w_ligter ; str_old_option = str_option ; break;}} / * str_end> 0 end * / break; case HOME: if (str_end> 0) {if (str_option == 0) {need_draw = 0; break;} str_old_option = str_option; str_option = 0; w_old_ligter = w_ligter; w_ligter = 0;} break; case END: if (str_end> 0) {if (str_option == str_end-1) {need_draw = 0; break;} str_old_option = str_option; str_option = str_end-1; w_old_ligter = w_ligter; if (str_end 0) {if (str_option == 0) {need_draw = 0; break;} must_redraw = 1; str_old_option = str_option; w_old_ligter = w_ligter; if (str_option-w_height * 2> = 0) {str_option- = w_height; break;} else str_option = w_ligter = 0;} break; case PGDN : IF (str_end> 0) {if (str_option == STR_END-1) {NEED_DRAW = 0; Break;} Must_redRAW = 1; STR _old_option = str_option; w_old_ligter = w_ligter; if (str_option w_height

INT WinReadtxt (Struct Creadtxt R) {Int x, Y, L, T; Struct CDialog BM; IF ((R.TXTBOTTOM-R.TXTTOP)% 16! = 0 || (R.TXTRIGHT-R.TXTLEFT)% 16 ! = 0) {systemRr1 = "function readxtFile error, boundary is not aligned"; systemError.Str2 = "The length & width of the display area should be 16 times"; MessageBox (& SystemError); Return (Error);} BM .title = r.txtFileName; bm.left = r.LEFT; bm.top = r.top; bm.right = r.right; bm.bottom = r.bottom; wl = r.txtLeft; wt = r.txttop WR = r.txtright; wb = r.txtbottom; bm.close = 1; bm.move = 1; bm.draw = null; bm.react = acttxtwinbutton; if ((txtfilehandle = fopen (R.TXTFileName, "RB ")) == NULL) RETURN (Error); IF (Initdialog (& BM) == Error) Return (Error); / * Sub INIT READTXT WINDOW * / Button (BM.right-20, BM.TOP 20, NULL , "U", button_up; button (BM.right-20, BM.BOTTOM-20, NULL, "D", Button_up); WinMake (BM.right-19, BM.TOP 22 16, BM.right -20 15, // * upper page * / bm.top 20 (BM.BOTTOM-BM.TOP-20) / 2, LightGray, Button_Frame, Button_UP); WinMake (BM.right-19, BM. TOP 22 (BM.BOTTOM-BM.TOP-20) / 2, BM.right-20 15, // * lower page * / bm.bottom 22, lightgray, button_frame, button_up; mouse_off (); ReadtxtFile (BM.LEFT WL, BM.TOP 22 WT, BM.LEFT WR, BM.TOP 22 WB, INITTXTWIN); mouse_on (); / * end init * / rundialog (& BM); fclose (txtfileHandle); return (ok);

INT ACTTXTWINBUTTON (INT MX, INT MY, STRUCT CDIALOG BM) {Int Key; IF (Inbar (MX, MX, MY, BM.right-19, BM.TOP 21 16, BM.right-20 16, / / ​​* PGUP * / BM.TOP 20 (BM.BOTTOM-BM.TOP-20) / 2)) Key = PGUP; IF (INBAR (MX, MX, MY, BM.right-19, Bm.top 22 (BM .bottom-bm.top-20) / 2, / / ​​* pgdn * / bm.right-20 16, bm.bottom-22)) Key = PGDN; IF (Inbar (MX, MX, MX, MY, BM.Right-20 , BM.TOP 20, BM.right-20 16, BM.TOP 20 16)) Key = Up; IF (Inbar (MX, MX, MY, BM.right-20, BM.BOTTOM-4-16, BM.right-20 16, bm.bottom-4)) Key = Down; if (key == UP || Key == Down || Key == PGUP || Key == PGDN) {mouse_off (); while (! Lbutton_up) ReadtxtFile (BM.LEFT WT, BM.TOP 22 WT, BM.LEFT WR, BM.TOP 22 WB, Key); reset_event_status (); mouse_on (); return (dialog_not_close); } IF (kBhit ()) {key = getKey (); clearKeyBuffer (); if (key == ESC) return (Dialog_close); if (key == Up || key == down || Key == PGUP || Key == PGDN) {mouse_off (); ReadtxtFile (BM.LEFT WL, BM.TOP 22 WT, BM.LEFT WR, BM.TOP 22 WB, Key); mouse_on (); Return (OK } / * If harve t Xtwinkey Is Pressed End * / Else Return (OK);}}

INTRETXTFILE (INT LEFT, INT TOP, INT RIGHT, INT BOTTOM, INT KEY) / * The length and width of the display area must be 16 multiples * / {char TMP [3]; char * linenumerr = "defined text line The number of texts smaller than the display "" static unsigned long count1, count2; static int x, y, maxline, linenum = 0; static long fileoffset; static unsigned char endflag, eoln; unsigned char CH1, CH2; int backActionButton = 0; / * when the display is completed, the response function of the return flag * / if (linenum> = MAXLINENUM) {SystemError.str1 = linenumerr; MessageBox (& SystemError); return (ERROR);} setfillstyle (SOLID_FILL, TXT_WIN_BACKGROUND); if (key! = INITTXTWIN) GOTO JMP_HERE; BAR (Left, Top, Right, Bottom); for (count1 = 1; count1 Right) count2- = 2; x = 16;

} Else {switch (CH1) {CASE '/ R': BREAK; CASE '/ N': Y = 16; x = Left; eoln = 1; lineaddr [ linenum] = fileoffset count2; break; case '/ T ': X = 64; Break; default: TMP [0] = CH1; TMP [1] =' / 0 '; setViewPort (Left, Top, Right, Bottom, 1); OutText (X-Left, Y-TOP , TXT_WIN_TEXT, TMP); SetViewPort (0, 0, 639, 479, 1); X = 8; Break;}} f (x> = Right) {lineAddr [ linenum] = fileoffset count2; y = 16; Eoln = 1;}}}} {systemror.Str1 = lineenumerr; messagebox (& system); return (error);}} ((y> = bottom) || (count1

转载请注明原文地址:https://www.9cbs.com/read-88717.html

New Post(0)