Figure 10-1: Original text in black, alpha text in gray, overlay showing gray text through black in Java

Drawer Quick Response Code in Java Figure 10-1: Original text in black, alpha text in gray, overlay showing gray text through black
Figure 10-1: Original text in black, alpha text in gray, overlay showing gray text through black
Recognize QR In Java
Using Barcode Control SDK for Java Control to generate, create, read, scan barcode image in Java applications.
10
Quick Response Code Creator In Java
Using Barcode generation for Java Control to generate, create QR Code JIS X 0510 image in Java applications.
More Window Tricks
QR Code JIS X 0510 Decoder In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
Sadly, you cannot use color in the program to show how overlay() works, similar to what s seen in Figure 10-1. Any text copied from one window to another takes on the attributes of the new window.
Barcode Drawer In Java
Using Barcode creation for Java Control to generate, create bar code image in Java applications.
The overwrite() difference
Barcode Reader In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
To see how overwrite() differs from overlay() is easy. Change lines 22 and 23 to read:
Painting QR Code In Visual C#.NET
Using Barcode maker for VS .NET Control to generate, create QR-Code image in VS .NET applications.
/* Copy text from one window to the other, destructively */ overwrite(stdscr,alpha);
Encode QR Code In .NET
Using Barcode creator for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
The overwrite() function is destructive, so no characters from the original text appear, peeking through Lorem ipsum as they did in the doop1.c program.
QR Code JIS X 0510 Creation In VS .NET
Using Barcode maker for Visual Studio .NET Control to generate, create QR Code image in .NET framework applications.
The magic of copywin()
Making QR Code In VB.NET
Using Barcode encoder for Visual Studio .NET Control to generate, create QR Code image in .NET applications.
The best of the three basic text-copying functions is copywin(), which allows you a great deal of control over which chunk of text is copied from the source window and where it ends up in the destination window. And unlike overlay() and overwrite(), copywin() seems to work on windows of any size. Here s the detailed format: copywin(swin,dwin,srow,scol,drow,dcol,dxrow,dxcol,type) The srcwin and destwin are the source and destination windows, which can be of any size or position on the screen. srow and scol are the starting coordinates of the chunk of text to be copied, as offset within the srcwin. drow and dcol set the starting coordinates of where the chunk will be copied into the destwin. The size of the chunk copied is set by dxrow and dxcol, which are offsets with destwin. Finally, type can be either TRUE or FALSE. If TRUE, then the text copied is non-destructive, as with overlay(). If FALSE, then the text block replaces the block in the destwin, just like overwrite(). I realize that s confusing, so I drew up Figure 10-2 to help you visualize things.
Barcode Creator In Java
Using Barcode creator for Java Control to generate, create barcode image in Java applications.
10
Code 39 Extended Encoder In Java
Using Barcode printer for Java Control to generate, create USS Code 39 image in Java applications.
srcwin 0,0
GTIN - 12 Generator In Java
Using Barcode printer for Java Control to generate, create UPC-A Supplement 5 image in Java applications.
More Window Tricks
Drawing USPS PLANET Barcode In Java
Using Barcode printer for Java Control to generate, create USPS Confirm Service Barcode image in Java applications.
sminrow
Printing EAN / UCC - 13 In .NET Framework
Using Barcode printer for .NET framework Control to generate, create GS1-128 image in VS .NET applications.
smincol
EAN 13 Encoder In Visual C#
Using Barcode creator for VS .NET Control to generate, create European Article Number 13 image in Visual Studio .NET applications.
dstwin 0,0
Data Matrix 2d Barcode Scanner In .NET Framework
Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
dminrow
Paint Code 128 Code Set A In Visual Studio .NET
Using Barcode creator for VS .NET Control to generate, create Code 128 Code Set A image in .NET applications.
dmincol
GS1 128 Printer In Visual Basic .NET
Using Barcode creator for .NET Control to generate, create EAN128 image in Visual Studio .NET applications.
dmaxrow
Data Matrix ECC200 Creation In Visual C#.NET
Using Barcode printer for .NET framework Control to generate, create Data Matrix image in .NET applications.
dmaxcol
Code 39 Reader In VS .NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in VS .NET applications.
Figure 10-2: A visual explanation of the copywin() function
Here s a sample program to toy with (see Listing 10.2).
Listing 10-2: doop3.c
1 #include <ncurses.h> 2 3 int main(void) 4 { 5 WINDOW *top,*bottom; 6 int maxx, maxy, halfx, halfy, rc; 7 char text1[] = Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. ; 8 char text2[]= Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. ; 9 10 initscr(); 11 12 /* Get window sizes */ 13 getmaxyx(stdscr,maxy,maxx); 14 halfy = maxy >> 1; 15 halfx = maxx >> 1; 16
(continued)
10
More Window Tricks
Listing 10-2 (continued)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 /* Build windows */ top = newwin(halfy,maxx,0,0); bottom = newwin(halfy,halfx,halfy,halfx); waddstr(top,text1); wrefresh(top); waddstr(bottom,text2); wrefresh(bottom); /* Wait for key press */ getch(); /* Copy text from top to bottom */ rc = copywin(top,bottom,0,0,0,0,4,12,FALSE); wrefresh(bottom); getch(); endwin(); return 0; }
For your real programs, remember to check for errors when creating the two windows in lines 19 and 20. The copywin() function uses the FALSE option, so the rectangle of text from window top overwrites the original contents of window bottom. Figure 10-3 may help you to see the results.
Figure 10-3: Cute graphical illustration of copywin()
10
More Window Tricks
Plain old window duplication
The final window copying function is dupwin(), which copies an entire window size, text and all to a new window, a duplicate. It s basically the newwin() function, but uses an existing window as a template to create the new window.
newwin = dupwin(win)
The dupwin() function returns a WINDOW pointer, which is then used to reference and write to the new window (Listing 10.3).
Listing 10-3: dup.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 #include <ncurses.h> int main(void) { WINDOW *fred,*barney; initscr(); /* Build window & wait */ fred = newwin(0,0,0,0); waddstr(fred, This is the original window, Fred.\n ); wrefresh(fred); getch(); /* Create and show barney */ barney = dupwin(fred); waddstr(barney, This is the Barney copy of window Fred.\n ); wrefresh(barney); getch(); /* Go back to fred */ waddstr(fred, Nice to see you again!\n ); wrefresh(fred); getch(); /* One more time to barney */ waddstr(barney, And Barney says Hi as well.\n ); touchwin(barney); wrefresh(barney); endwin(); return 0; }