/************************************************************************
 * Title:        !SeeThruMyRedactionsWithBorders.cpl                    *
 *                                                                      *
 * Description:  Toggle the transparency of the redaction boxes         *
 *               (but keep the borders intact)                          *
 *                                                                      *
 * Usage:        This CPL should be run from your redlines.dcb file     *
 *                                                                      *
 * Author:       Calvin Smith                                           *
 * Email:        JobForCalvin@Yahoo.com                                 *
 * Web:          www.CalvinSmithSoftware.com                            * 
 * Compiler:     Concordance                                            *
 * Accepts:      Nothing                                                *
 * CPL Version:  1.0                                                    *
 ************************************************************************
 *                                                                      *
 * NOTE: Contact me if you need a custom CPL developed for other needs. *
 *                                                                      *
 ************************************************************************/

text DEFAULT = "REDACTION";
text DEFAULTALT = "HOLLOWBOX";

main()
{

int db;
text UserPrompt1;
text UserPrompt2;
text Msg1;
text Msg2;

	UserPrompt1 = "This CPL will toggle the transparency of the redaction boxes "+
		 "while leaving the borders intact to always see where the redactions are. "+
		 chr(CR)+chr(LF)+ 
		 "         Press any key to continue...";
		 
	UserPrompt2 = "Continue flipping the transparency of the redactions?";

	Msg1 = "Concordance CPL To Flip The Transparency Of Redaction Boxes";
	Msg2 = "One moment please...";

	cursoroff();
	Status(db,Msg1);
	puts(0,0,program(),MenuColor_);
	scroll(07,15,15,62,0,0,MenuColor_);
	box(07,14,13,65,"3D",MenuColor_);
	edit(UserPrompt1,08,16,13,61,-1,1,1,MenuColor_);

      	if (getkey() == ESC)
      	{
        	return;
        }
      	else
	{	cursor(0,0);
		cursoroff();
		puts(0,0,pad("Blank Field",'C',80),MenuHighlight_);
	}

   	if (messageBox(UserPrompt2,"Confirm Process",MB_OKCANCEL) == IDOK)
   	{
   	
		puts(0,0,program(),MenuColor_);
		scroll(07,15,15,62,0,0,MenuColor_);
		box(07,14,13,65,"3D",MenuColor_);
		edit(Msg2,08,16,13,61,-1,1,1,MenuColor_);
		
		cycle(db) {
			switch(db->TYPE) {

				case DEFAULT:
					db->TYPE=DEFAULTALT;
					break;
				case DEFAULTALT:
					db->TYPE=DEFAULT;
					break;
			}
		}
		reindex(db);
   	}
    	else
    	{
    		cls();
    		UserPrompt1 = "Operation cancelled."+ chr(CR)+chr(LF)+ chr(CR)+chr(LF)+ " Press any key to continue...";
    		Message (UserPrompt1);
    		return;
   	}
}

Message(text message)
{
text screen;
int key;
   cursoroff();
   screen = save(8,13,11,69);
   box(8,13,11,69,"3D", MenuColor_);
   puts(9,14,pad(message,'C',53),MenuColor_);
   key = getkey();
   restore(8,13,screen);
   return(asc(upper(chr(key))));
} /* Message() */

Status(int db; text Msg)
{
   puts(0,0,rep('_',80),MenuColor_);
   puts(MaxRow_,0,rep(' ',80),MenuColor_);
   puts(MaxRow_,0,Msg,MenuColor_);
   if (db.documents >= 0)
   puts(0,0,db.database,MenuColor_);
} /* Status() */

/****************************************************************
* Global Variable Declarations and Initialization               *
****************************************************************/

char    ESC = 27,
        CTRLP = 16,
        FALSE = 0,
        TRUE = 1,
        CR = 13,
        LF = 10;
text    NL = chr(CR)+chr(LF);