![]() |
![]() HP OpenVMS Systems Documentation |
![]() |
DECwindows Motif Guide to Application Programming
7.8 Creating the Print Widget with a Toolkit RoutineExample 7-6 shows how the print widget for the OpenVMS DECburger example was created using the DXmCreatePrintDialog routine.
7.9 Submitting Print JobsAfter you have created an instance of the print widget through either UIL or the Toolkit routine, you must submit the print job to the printer queue. The DXmPrintWgtPrintJob routine is provided for this purpose. You pass the ID of the print widget, a list of the files to print, and the number of files to print to the DXmPrintWgtPrintJob routine. Example 7-7 shows an example of calling the DXmPrintWgtPrintJob routine from the OpenVMS DECburger example program.
Chapter 8
|
Routine Name | Description |
---|---|
Manipulating the Text Content of the Widget | |
DXmCSTextCopy | Copies the currently selected (highlighted) text to the clipboard. |
DXmCSTextCut | Deletes the currently selected (highlighted) text after copying it to the clipboard. |
DXmCSTextGetString | Returns the compound string that is the current value of the CSText widget. |
DXmCSTextInsert | Inserts the new compound string into the compound string at the specified position. |
DXmCSTextNumLines | Returns the number of output lines in the compound string text widget. |
DXmCSTextPaste | Pastes the data on the clipboard into the text at the current cursor position. |
DXmCSTextRemove | Removes the currently selected (highlighted) text. |
DXmCSTextReplace | Replaces the compound string characters between "from" and "to" with the given string; "from" and "to" are zero-based character offsets that include new lines. |
DXmCSTextSetString | Replaces the text of the CSText widget with completely new text. |
DXmCSTextHorizontalScroll | Scrolls text by the given number of pixels. |
DXmCSTextGetEditable | Returns a Boolean value that indicates whether the user of the application can edit the current text contents of the widget. When this routine returns TRUE (1), the user can edit the text; when it returns FALSE (0), the user cannot edit the text. |
DXmCSTextGetInsertionPosition | Returns the position (offset) of the insertion cursor. |
DXmCSTextGetLastPosition | Returns the position (offset) corresponding to the last character in the string. |
DXmCSTextGetMaxLength | Returns the maximum length of text that the widget will allow a user to enter. |
DXmCSTextGetTopPosition | Returns the position (offset) of the top left (or top right) character in the displayed text. |
DXmCSTextPosToXY | Identifies the x and y positions of a specified character in the text. |
DXmCSTextXYToPos | Identifies the position in the text of the character nearest to a specified x and y position. |
DXmCSTextHorizontalScroll | Scrolls text by the given number of pixels. |
DXmCSTextSetAddMode | Controls whether the CSText widget is in Add Mode, which allows the user to move the insert cursor without affecting the primary selection. |
DXmCSTextSetEditable | Sets the Boolean value that indicates whether the user can edit the current text contents of the CSText widget. To allow editing, set this value to TRUE. |
DXmCSTextSetHighlight | Changes the highlighting mode of a compound string. |
DXmCSTextSetInsertionPosition | Sets the insertion cursor to the given position (offset) in the source. |
DXmCSTextSetMaxLength | Sets a size limit in characters, including newline characters, that the user can enter in the widget. |
DXmCSTextSetTopPosition | Sets the position (offset), which will be at the top left (or top right) of the displayed text. |
DXmCSTextShowPosition | Forces the given position to be displayed. |
DXmCSTextVerticalScroll | Scrolls text by the specified number of lines. |
DXmCSTextClearSelection | Cancels the selection of compound string text in the widget and turns off highlighting of the text. |
DXmCSTextGetSelection | Gets the portion of the compound string text that has been selected using the selection mechanism. Selected text is highlighted on the display. |
DXmCSTextGetSelectionInfo | Returns the left and right positions (offsets) corresponding to the currently selected (highlighted) text. Returns FALSE if there is no currently selected text. |
DXmCSTextHasSelection | Returns TRUE if the compound string text widget currently owns the primary selection. |
DXmCSTextSetSelection | Sets the portion of the compound string text specified by the start and end point positions as the selection, and highlights the text on the screen. |
The following sections describe how to use the resources of the CSText
widget and the CSText widget support routines.
8.2.1 Manipulating the Text Contents of the CSText Widget
The CSText widget provides text entry and text editing capabilities in a user interface. To manipulate the text contents of the CSText widget at run time (after the widget has been created), you can use either of the following two sets of routines:
The support routines offer several advantages over the XtSetValues or XtGetValues:
To place a compound string in a CSText widget after the widget has been created, you can use the XtSetValues intrinsic routine or a support routine.
To use the XtSetValues intrinsic routine, specify the address of the compound string as the value of the XmNvalue resource in an argument list. (The default is null.) Then pass this argument list to the XtSetValues intrinsic routine to assign the value to the widget resource.
You can use the CSText widget support routines to either modify the text the widget contains or replace the text entirely.
Use the DXmCSTextReplace support routine to modify the text currently in the CSText widget. This routine takes the following arguments:
Specify the position in the text as an offset from the beginning. Determine the offset by counting the characters, including spaces and new lines. The first character is numbered 0 (zero). Successive characters are numbered sequentially.
Use the DXmCSTextInsert routine to insert a new compound string into the compound string text source at the specified position. Specify the same position for both the start and the end points. If the start and end points are not specified as the same position, the text in the section defined by the start and end points is replaced by the new text.
Use the DXmCSTextPaste routine to insert the data on the clipboard into the text at the current cursor position.
Use the DXmCSTextSetString routine to replace all the text in a CSText
widget. This routine places the address of the new text in the
XmNvalue resource.
8.2.1.2 Retrieving Compound Strings from a CSText Widget
To retrieve the current value of a CSText widget, you can use the XtGetValues intrinsic routine or a support routine.
To use the XtGetValues intrinsic routine, create a variable to hold the address of the compound string and specify this variable as the value of the XmNvalue resource in an argument list. Then pass this argument list to the XtGetValues intrinsic routine. The XtGetValues intrinsic routine writes the address contained in the XmNvalue resource into the variable that you specified in the argument list. Do not free the returned pointer.
Use the DXmCSTextGetString support routine to retrieve the current contents of the CSText widget. This support routine returns the value of the XmNvalue resource. Free the returned pointer.
Example 8-1 shows how to use the DXmCSTextGetString routine.
Example 8-1 Using the DXmCSTextGetString Support Routine |
---|
. . . static void change_cs(w, tag, reason) Widget w; int *tag; XmNanyCallbackStruct *reason; { int ac = 0; Arg arglist[15]; XmString new_text; XtCallbackRec ok_arg[2]; new_text = DXmCSTextGetString(w); ac = 0; XtSetArg( arglist[ac], XmNdialogTitle, new_text);ac++; XtSetValues (text_shell, arglist, ac); . . . XtFree(new_text); . . . } |
Previous | Next | Contents | Index |