Writing a Tk Widget in C in .NET Add qr-codes in .NET Writing a Tk Widget in C

How to generate, print barcode using .NET, Java sdk library control with example project source code free download:
Writing a Tk Widget in C use visual studio .net qrcode printing todevelop qr barcode for .net EAN-13 Chap.31 clockPtr->inte rp = interp; clockPtr->borderWidth = 0; clockPtr->highlightWidth = 0; clockPtr->relief = TK_RELIEF_FLAT; clockPtr->background = NULL; clockPtr->foreground = NULL; clockPtr->highlight = NULL; clockPtr->fontPtr = NULL; clockPtr->textGC = None; clockPtr->highlightGC = None; clockPtr->token = NULL; clockPtr->clock = NULL; clockPtr->numChars = 0; clockPtr->textWidth = 0; clockPtr->textHeight = 0; clockPtr->flags = 0; /* * Register a handler for when the window is * exposed or resized. */ Tk_CreateEventHandler(clockPtr->tkwin, ExposureMask. StructureNotifyMask FocusChangeMask, ClockEventProc, (ClientData) clockPtr); /* * Create a Tcl command that operates on the widget. */ Tcl_CreateCommand(interp, Tk_PathName(clockPtr->tkwin), ClockInstanceCmd, (ClientData) clockPtr, (void (*)()) NULL); /* * Parse the command line arguments. */ if (ClockConfigure(interp, clockPtr, argc-2, argv+2, 0) != TCL_OK) { Tk_DestroyWindow(clockPtr->tkwin); return TCL_ERROR; } interp->result = Tk_PathName(clockPtr->tkwin); return TCL_OK; }.

Widget Instance Command For each instance of a widget a new command is created that operates on that widget. This is called the widget instance command. Its name is the same as the Tk pathname of the widget.

In the clock example, all that is done on instances is to query and change their attributes. Most of the work is done by Tk_ConfigureWidget and ClockConfigure, which is shown in the next section. The ClockInstanceCmd command procedure is shown in the next exmaple.

. Created: December VS .NET qr-codes 15, 1994 CTkWidget.fm3 Copyright Prentice Hall DRAFT: 1/13/95.

Widget Instance Command Example 31 4 The ClockInstanceCmd command procedure. static int ClockI QR for .NET nstanceCmd(clientData, interp, argc, argv) ClientData clientData; /* A pointer to a Clock struct */ Tcl_Interp *interp; /* The interpreter */ int argc; /* The number of arguments */ char *argv[]; /* The command line arguments */ { Clock *clockPtr = (Clock *)clientData; int result = TCL_OK; char c; int length; if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be "", argv[0], " option arg arg ..

. "", (char *) NULL); return TCL_ERROR; } c = argv[1][0]; length = strlen(argv[1]); if ((c == c ) && (strncmp(argv[1], "cget", length) == 0) && (length >= 2)) { if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be "", argv[0], " cget option"", (char *) NULL); return TCL_ERROR; } result = Tk_ConfigureValue(interp, clockPtr->tkwin, configSpecs, (char *) clockPtr, argv[2], 0); } else if ((c == c ) && (strncmp(argv[1], "configure", length) == 0) && (length >= 2)) { if (argc == 2) { /* * Return all configuration information. */ result = Tk_ConfigureInfo(interp, clockPtr->tkwin, configSpecs, (char *) clockPtr, (char *) NULL,0); } else if (argc == 3) { /* * Return info about one attribute, like cget.

*/ result = Tk_ConfigureInfo(interp, clockPtr->tkwin, configSpecs, (char *) clockPtr, argv[2], 0); } else { /* * Change one or more attributes. */ result = ClockConfigure(interp, clockPtr, argc-2, argv+2,TK_CONFIG_ARGV_ONLY); }. Created: December 15, 1994 CTkWidget.fm3 Copyright Prentice Hall DRAFT: 1/13/95. Writing a Tk Widget in C Chap.31 } else { Tcl_Appe QR Code 2d barcode for .NET ndResult(interp, "bad option "", argv[1], "": must be cget, configure, position, or size", (char *) NULL); return TCL_ERROR; } return result; }. Con guring And Recon guring Attributes When the widget i VS .NET QR s created or recon gured, then the implementation needs to allocate the resources implied by the attribute settings. Each clock widget uses some colors and a font.

These are described by graphics contexts. A graphic context is used by X to parameterize graphic operations. Instead of specifying every possible attribute in the X calls, a graphics context is initialized with a subset of the parameters and this is passed into the X drawing commands.

The context can specify the foreground and background colors, clip masks, line styles, and so on. In the example, two different graphics contexts are used, one for the highlight rectangle and one for the text and background. They use different colors, so different contexts are needed.

The graphics contexts are allocated once and reused each time the widget is displayed. There are two kinds of color resources used by the widget. The focus highlight and the text foreground are simple colors.

The background is a Tk_3DBorder, which is a set of colors used to render 3D borders. The background color is speci ed in the attribute, and the other colors are computed based on that color . The code uses Tk_3DBorderColor to map back to the originial color for use in the background of the widget.

After the resources are set up, a call to redisplay the widget is scheduled for the next idle period. This is a standard idiom for Tk widgets. It means that you can create and recon gure a widget in the middle of a script, and all the changes only result in one redisplay.

The REDRAW_PENDING ag is used to ensure that only one redisplay is queued up at any time. The ClockConfigure procedure is shown in the next example..

Copyright © . All rights reserved.