749N/ACopyright (c) 1989, 1994 X Consortium 749N/APermission is hereby granted, free of charge, to any person obtaining a copy 749N/Aof this software and associated documentation files (the "Software"), to deal 749N/Ain the Software without restriction, including without limitation the rights 749N/Ato use, copy, modify, merge, publish, distribute, sublicense, and/or sell 749N/Acopies of the Software, and to permit persons to whom the Software is 749N/Afurnished to do so, subject to the following conditions: 749N/AThe above copyright notice and this permission notice shall be included in 749N/Aall copies or substantial portions of the Software. 749N/ATHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 749N/AIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 749N/AFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 749N/AX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 749N/AAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 749N/ACONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 749N/AExcept as contained in this notice, the name of the X Consortium shall not be 749N/Aused in advertising or otherwise to promote the sale, use or other dealings 749N/Ain this Software without prior written authorization from the X Consortium. 749N/A/************************************************************ 749N/A * This file is broken up into three sections one dealing with 749N/A * each of the three popups created here: 749N/A * FileInsert, Search, and Replace. 749N/A * There is also a section at the end for utility functions 749N/A * used by all more than one of these dialogs. 749N/A * The following functions are the only non-static ones defined 749N/A * in this module. They are located at the begining of the 749N/A * section that contains this dialog box that uses them. 749N/A * void _XawTextInsertFileAction(w, event, params, num_params); 749N/A * void _XawTextDoSearchAction(w, event, params, num_params); 749N/A * void _XawTextDoReplaceAction(w, event, params, num_params); 749N/A * void _XawTextInsertFile(w, event, params, num_params); 749N/A *************************************************************/ 749N/A "<Btn1Down>,<Btn1Up>: set() notify()";
749N/A "~Shift<Key>Return: DoSearchAction(Popdown) \n\ 749N/A Shift<Key>Return: DoSearchAction() SetField(Replace) \n\ 749N/A Ctrl<Key>q,<Key>Tab: insert-char() \n\ 749N/A Ctrl<Key>c: PopdownSearchAction() \n\ 749N/A <Btn1Down>: select-start() SetField(Search) \n\ 749N/A <Key>Tab: DoSearchAction() SetField(Replace)";
749N/A "~Shift<Key>Return: DoReplaceAction(Popdown) \n\ 749N/A Shift<Key>Return: SetField(Search) \n\ 749N/A Ctrl<Key>q,<Key>Tab: insert-char() \n\ 749N/A Ctrl<Key>c: PopdownSearchAction() \n\ 749N/A <Btn1Down>: select-start() DoSearchAction() SetField(Replace)\n\ 749N/A <Key>Tab: SetField(Search)";
749N/A/************************************************************ 749N/A * This section of the file contains all the functions that 749N/A * the file insert dialog box uses. 749N/A ************************************************************/ 749N/A/* Function Name: _XawTextInsertFileAction 749N/A * Description: Action routine that can be bound to dialog box's 749N/A * Text Widget that will insert a file into the main 749N/A * Arguments: (Standard Action Routine args) 749N/A/* Function Name: _XawTextInsertFile 749N/A * Description: Action routine that can be bound to the text widget 749N/A * it will popup the insert file dialog box. 749N/A * Arguments: w - the text widget. 749N/A * event - X Event (used to get x and y location). 749N/A * params, num_params - the parameter list. 749N/A * The parameter list may contain one entry. 749N/A * Entry: This entry is optional and contains the value of the default 749N/A/* Function Name: PopdownFileInsert 749N/A * Description: Pops down the file insert button. 749N/A * Arguments: w - the widget that caused this action. 749N/A * closure - a pointer to the main text widget that 749N/A * popped up this dialog. 749N/A * call_data - *** NOT USED ***. 749N/A/* Function Name: DoInsert 749N/A * Description: Actually insert the file named in the text widget 749N/A * Arguments: w - the widget that activated this callback. 749N/A * closure - a pointer to the text widget to insert the 749N/A "*** Error: Could not get text widget from file insert popup");
749N/A/* Function Name: InsertFileNamed 749N/A * Description: Inserts a file into the text widget. 749N/A * Arguments: tw - The text widget to insert this file into. 749N/A * str - name of the file to insert. 749N/A * Returns: TRUE if the insert was sucessful, FALSE otherwise. 749N/A /* DELETE if (text.format == XawFmtWide) { 749N/A wchar_t* _XawTextMBToWC(); 749N/A wstr = _XawTextMBToWC(XtDisplay(tw), text.ptr, &(text.length)); 749N/A wstr[text.length] = NULL; 749N/A text.ptr = (char *)wstr; 749N/A (text.ptr)[text.length] = '\0'; 749N/A/* Function Name: AddInsertFileChildren 749N/A * Description: Adds all children to the InsertFile dialog widget. 749N/A * Arguments: form - the form widget for the insert dialog widget. 749N/A * ptr - a pointer to the initial string for the Text Widget. 749N/A * tw - the main text widget. 749N/A * Bind <CR> to insert file. 749N/A/************************************************************ 749N/A * This section of the file contains all the functions that 749N/A * the search dialog box uses. 749N/A ************************************************************/ 749N/A/* Function Name: _XawTextDoSearchAction 749N/A * Description: Action routine that can be bound to dialog box's 749N/A * Text Widget that will search for a string in the main 749N/A * Arguments: (Standard Action Routine args) 749N/A * If the search was sucessful and the argument popdown is passed to 749N/A * this action routine then the widget will automatically popdown the 749N/A/* Function Name: _XawTextPopdownSearchAction 749N/A * Description: Action routine that can be bound to dialog box's 749N/A * Text Widget that will popdown the search widget. 749N/A * Arguments: (Standard Action Routine args) 749N/A/* Function Name: PopdownSeach 749N/A * Description: Pops down the search widget and resets it. 749N/A * Arguments: w - *** NOT USED ***. 749N/A * closure - a pointer to the search structure. 749N/A * call_data - *** NOT USED ***. 749N/A/* Function Name: SearchButton 749N/A * Description: Performs a search when the button is clicked. 749N/A * Arguments: w - *** NOT USED **. 749N/A * closure - a pointer to the search info. 749N/A * call_data - *** NOT USED ***. 749N/A/* Function Name: _XawTextSearch 749N/A * Description: Action routine that can be bound to the text widget 749N/A * it will popup the search dialog box. 749N/A * Arguments: w - the text widget. 749N/A * event - X Event (used to get x and y location). 749N/A * params, num_params - the parameter list. 749N/A * The parameter list contains one or two entries that may be the following. 749N/A * First Entry: The first entry is the direction to search by default. 749N/A * This arguement must be specified and may have a value of 749N/A * Second Entry: This entry is optional and contains the value of the default 749N/A * string to search for. 749N/A "This action must have only",
749N/A "one or two parameters");
749N/A /*This just does the equivalent of ptr = ""L, a waste because params[1] isnt W aligned.*/ 749N/A "The first parameter must be",
749N/A "Either 'backward' or 'forward'");
749N/A/* Function Name: InitializeSearchWidget 749N/A * Description: This function initializes the search widget and 749N/A * is called each time the search widget is poped up. 749N/A * Arguments: search - the search widget structure. 749N/A * dir - direction to search. 749N/A * replace_active - state of the sensitivity for the 749N/A/* Function Name: AddSearchChildren 749N/A * Description: Adds all children to the Search Dialog Widget. 749N/A * Arguments: form - the form widget for the search widget. 749N/A * ptr - a pointer to the initial string for the Text Widget. 749N/A * tw - the main text widget. 749N/A * We need to add R_OFFSET to the radio_data, because the value zero (0) 749N/A * Initialize the text entry fields. 749N/A * Bind Extra translations. 749N/A/* Function Name: DoSearch 749N/A * Description: Performs a search. 749N/A * Arguments: search - the serach structure. 749N/A * Returns: TRUE if sucessful. 749N/A /* The Raw string in find.ptr may be WC I can't use here, so I re - call 749N/A GetString to get a tame version. */ 749N/A char*
fmt =
"Could not find string \"%s\"";
749N/A/************************************************************ 749N/A * This section of the file contains all the functions that 749N/A * the replace dialog box uses. 749N/A ************************************************************/ 749N/A/* Function Name: _XawTextDoReplaceAction 749N/A * Description: Action routine that can be bound to dialog box's 749N/A * Text Widget that will replace a string in the main 749N/A * Arguments: (Standard Action Routine args) 749N/A/* Function Name: DoReplaceOne 749N/A * Description: Replaces the first instance of the string 749N/A * in the search dialog's text widget 749N/A * with the one in the replace dialog's text widget. 749N/A * Arguments: w - *** Not Used ***. 749N/A * closure - a pointer to the search structure. 749N/A * call_data - *** Not Used ***. 749N/A/* Function Name: DoReplaceOne 749N/A * Description: Replaces every instance of the string 749N/A * in the search dialog's text widget 749N/A * with the one in the replace dialog's text widget. 749N/A * Arguments: w - *** Not Used ***. 749N/A * closure - a pointer to the search structure. 749N/A * call_data - *** Not Used ***. 749N/A/* Function Name: Replace 749N/A * Description: This is the function that does the real work of 749N/A * replacing strings in the main text widget. 749N/A * Arguments: tw - the Text Widget to replce the string in. 749N/A * once_only - If TRUE then only replace the first one found. 749N/A * other replace all of them. 749N/A * show_current - If true then leave the selection on the 749N/A * string that was just replaced, otherwise 749N/A * move it onto the next one. 749N/A char*
fmt =
"*** Error: Could not find string \"%s\" ***";
749N/A/* Function Name: SetSearchLabels 749N/A * Description: Sets both the search labels, and also rings the bell 749N/A * Arguments: search - the search structure. 749N/A * msg1, msg2 - message to put in each search label. 749N/A * bell - if TRUE then ring bell. 749N/A/************************************************************ 749N/A * This section of the file contains utility routines used by 749N/A * other functions in this file. 749N/A ************************************************************/ 749N/A/* Function Name: _XawTextSetField 749N/A * Description: Action routine that can be bound to dialog box's 749N/A * Text Widget that will send input to the field specified. 749N/A * Arguments: (Standard Action Routine args) 749N/A "be either 'Search' or 'Replace'. ***",
TRUE);
749N/A/* Function Name: SetField 749N/A * Description: Sets the current text field. 749N/A * Arguments: new, old - new and old text fields. 749N/A/* Function Name: SetResourceByName 749N/A * Description: Sets a resource in any of the dialog children given 749N/A * name of the child and the shell widget of the dialog. 749N/A * Arguments: shell - shell widget of the popup. 749N/A * name - name of the child. 749N/A * res_name - name of the resource. 749N/A * value - the value of the resource. 749N/A * Returns: TRUE if sucessful. 749N/A/* Function Name: SetResource 749N/A * Description: Sets a resource in a widget 749N/A * Arguments: w - the widget. 749N/A * res_name - name of the resource. 749N/A * value - the value of the resource. 749N/A/* Function Name: GetString{Raw} 749N/A * Description: Gets the value for the string in the popup. 749N/A * Arguments: text - the text widget whose string we will get. 749N/A * GetString returns the string as a MB. 749N/A * GetStringRaw returns the exact buffer contents suitable for a search. 749N/A/* Function Name: CenterWidgetOnPoint. 749N/A * Description: Centers a shell widget on a point relative to 749N/A * Arguments: w - the shell widget. 749N/A * event - event containing the location of the point 749N/A * NOTE: The widget is not allowed to go off the screen. 749N/A/* Function Name: CreateDialog 749N/A * Description: Actually creates a dialog. 749N/A * Arguments: parent - the parent of the dialog - the main text widget. 749N/A * ptr - initial_string for the dialog. 749N/A * name - name of the dialog. 749N/A * func - function to create the children of the dialog. 749N/A * Returns: the popup shell of the dialog. 749N/A * The function argument is passed the following arguements. 749N/A * form - the from widget that is the dialog. 749N/A * ptr - the initial string for the dialog's text widget. 749N/A * parent - the parent of the dialog - the main text widget. 749N/A /* Function Name: GetShell 749N/A * Description: Walks up the widget hierarchy to find the 749N/A * nearest shell widget. 749N/A * Arguments: w - the widget whose parent shell should be returned. 749N/A * Returns: The shell widget among the ancestors of w that is the 749N/A * fewest levels up in the widget hierarchy. 749N/A for (i=0; i < n; p++, i++)
749N/A /* Respond to a recognized WM protocol request iff 749N/A * event type is ClientMessage and no parameters are passed, or 749N/A * event type is ClientMessage and event data is matched to parameters, or 749N/A * event type isn't ClientMessage and parameters make a request. 749N/A /* parse translation table once */ 749N/A (
"<Message>WM_PROTOCOLS: XawWMProtocols()\n");
749N/A /* add actions once per application context */ 749N/A /* establish communication between the window manager and each shell */