home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
CLIPPER
/
SYSWIN
/
SYSWIN.PRG
< prev
next >
Wrap
Text File
|
1992-05-16
|
9KB
|
188 lines
/**************************************************************************
** SYSWIN.PRG CLIPPER VERSION 5.0 Save & Restore Screen funcs**
** Functions which save and restore screen & color attributes **
** based upon a static array stack. These are replacement functions **
** for those located in FUNCS.CH header file. **
** Copyright notice: **
** Copyright (c) 1992, Roderick Jay Cushman. All rights reserved. **
** ----------------------------------------------------------------- **
** You may use these functions freely so long as this and **
** the function headers remain intact. You may use these functions **
** as part of your applications so long as the functions in this **
** file are not sold for profit. **
** Author : Rod Cushman **
** Revision Date : 05/16/92 00:02am **
**************************************************************************/
#include "BOX.CH" && Includes constants, functions, ...
#xcommand DEFAULT <foo> to <bar> => ;
If( <foo> == NIL, <foo> := <bar>, NIL )
/* Array is necessary for operation of Sav_SWIN2() and Rst_Swin2() */
static Scr_Stack := {}
#define SCR_TOP 1 /** Scr_Stack{} Top Row index **/
#define SCR_LFT 2 /** Scr_Stack{} Left Column index **/
#define SCR_BOT 3 /** Scr_Stack{} Bottom Row index **/
#define SCR_RIT 4 /** Scr_Stack{} Right Column index **/
#define SCR_COLOR 5 /** Scr_Stack{} Color index **/
#define SCR_SCREEN 6 /** Scr_Stack{} Screen Str index **/
#define SCR_LSHADE 7 /** Scr_Stack{} Shaded Scr? index **/
/**************************************************************************
** Creates a shaded window, save the color and screen onto the screen**
** stack prior to creating box. The color is set to cColor value. **
** Call with the following parameters: **
** nTop : Top Row of the box. **
** nLft : Left column of the box. **
** nBot : Bottom Row of the box. **
** nRit : Right column of the box. **
** cColor : Color which to display box in. **
** lShade : Logical: Shaded box ? Defaults to Yes. **
** **
** copyright (c) 1992, Roderick Jay Cushman. All Rights reserved. **
** Author : Rod Cushman **
** Revision Date : 05/15/92 07:58pm **
**************************************************************************/
Function SAV_SWIN2( nTop, nLft, nBot, nRit, cColor, lShade )
Local sWin, oColor
DEFAULT cColor to SetColor()
DEFAULT lShade to .t.
oColor := SetColor( cColor )
If lShade
sWin := Savescreen(nTop, nLft, nBot+1, nRit+2)
RestScreen( nTop+1,nLft+2,nBot+1,nRit+2, ;
Transform( SaveScreen( nTop+1,nLft+2,nBot+1,nRit+2 ), ;
Replicate( 'X' , ( nBot-nTop+1 )*( nRit-nLft+1 ) ) ) )
* Replicate( Chr(177), ( nBot-nTop+1 )*( nRit-nLft+1) ) ) )
Else
sWin := Savescreen(nTop, nLft, nBot, nRit)
EndIf
__BoxD( nTop, nLft, nBot, nRit )
__ATClear( nTop+1, nLft+1, nBot-1, nRit-1 )
Aadd( Scr_Stack, { nTop, nLft, nBot, nRit, oColor, sWin, lShade } )
Return( Len(Scr_Stack) )
/**************************************************************************
** Restores screen & color information saved onto the Screen Stack **
** via the SAV_SWIN2() function. Functions restores the last window **
** saved via a call to SAV_SWIN2(). Color is also restored from the **
** last call to SAV_SWIN2(). **
** copyright (c) 1992, Roderick Jay Cushman. All Rights reserved. **
** Author : Rod Cushman **
** Revision Date : 05/08/92 01:00pm **
**************************************************************************/
Function RST_SWIN2( )
Local cColor := "", anXY := {}
Local ele := Len( Scr_Stack )
If ele > 0 /* Ensure elements exist in Environment Stack */
/* Reset Color */
DispBegin()
cColor := SetColor( Scr_Stack[ ele, SCR_COLOR] )
/* Restore Screen if one was stored in SAV_SWIN2() */
If Scr_Stack[ele, SCR_LSHADE] // Was Shaded region saved ?
RestScreen(Scr_Stack[ele, SCR_TOP] , Scr_Stack[ele, SCR_LFT] , ;
Scr_Stack[ele, SCR_BOT]+1, Scr_Stack[ele, SCR_RIT]+2, ;
Scr_Stack[ele, SCR_SCREEN] )
Else
RestScreen(Scr_Stack[ele, SCR_TOP], Scr_Stack[ele, SCR_LFT], ;
Scr_Stack[ele, SCR_BOT], Scr_Stack[ele, SCR_RIT], ;
Scr_Stack[ele, SCR_SCREEN] )
EndIf
DispEnd()
anXY := ASize( Aclone(Scr_Stack[ele]), 4) /* Screen coordinates */
Asize( Scr_Stack, ele - 1) /* Decrease stack by one element */
/* Return lSuccess := .t., settings */
Return({ .t., cColor, anXY } )
Endif
Return({ .f., cColor, anXY } )
/****================ MISCELLANEOUS FUNCTIONS ========================****/
/**************************************************************************
** Clears the area of the screen: ntop,nleft -> nbot,nright Color cColor **
**************************************************************************/
Function CLR_WIN
Parameters nTop, nLeft, nBot, nRight, cColor, cBorder
Local cOColor
DEFAULT cColor TO SetColor()
DEFAULT cBorder TO B_DOUBLE + Space(1) && Relies on box.ch
DispBegin()
tColor := SetColor()
Set Color to && Reset color to default
SetColor( cColor )
@ nTop,nLeft,nBot,nRight Box cBorder
DispEnd()
Return(cOColor)
/**************************************************************************
** Function DispWin **
** clear window area and draw box for window **
**************************************************************************/
Function DispWin
Parameters nT,nL,nB,nR, cColor /* top row, bot. row, etc */
DEFAULT cColor TO SetColor()
SetColor( cColor )
DispBegin()
* @ nT,nL CLEAR TO nB,nR
@ nT,nL,nB,nR BOX B_DOUBLE_SINGLE+Space(1) Color cColor && Relies on box.ch
DispEnd()
Return NIL
/**************************************************************************
** The following function is part of Steve Straley's TooLkiT (tm) **
** - Release 2, published by Four Seasons Publishing Co., Inc. All **
** Rights Reserved. Information: 212-599-2141 / 800-662-2278. All **
** Rights Reserved. **
** This function takes a screen string and returns it with **
** the attribute byte dulled. **
**************************************************************************/
Function SCR_DULLING( cStr )
Local tStr := "", i := 1
For i := 1 to Len( cStr ) Step 2
tStr += SubStr( cStr, i, 1) + Chr(8)
Next i
Return( t_str )
/**************************************************************************
** Function returns the screen display as a string, including line- **
** feeds, minus the attribute byte. Parameters specify coordinates **
** to be parsed. **
**************************************************************************/
Function SCR_TO_TXT( nTop, nLft, nBot, nRit )
Local RetStr := "", tStr := "", i := 1, tRow := 0, tCol :=0
tStr := SaveScreen( nTop, nLft, nBot, nRit )
For tRow := 1 to nBot - nTop + 1
For tCol := 1 to nRit - nLft + 1 Step 2
RetStr += SubStr( cStr, i, 1)
Next tCol
RetStr += Chr(13) && Place Carriage Return at end of row
Next tRow
Return( RetStr )