749N/A/* $XConsortium: List.c,v 1.39 94/04/17 20:12:15 kaleb Exp $ */ 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 * This is a List widget. It allows the user to select an item in a list and 749N/A * notifies the application through a callback function. 749N/A * By: Chris D. Peterson 749N/A/* These added so widget knows whether its height, width are user selected. 749N/AI also added the freedoms member of the list widget part. */ 749N/A * Default Translation table. 749N/A/**************************************************************** 749N/A * Full class record constant 749N/A ****************************************************************/ 749N/A /* class_name */ "List",
749N/A/* Simple class fields initialization */ 749N/A/* List class fields initialization */ 749N/A/**************************************************************** 749N/A ****************************************************************/ 749N/A * but won't hurt if accidently called 749N/A * These calculations were needed in SetValues. They were in ResetList. 749N/A * ResetList called ChangeSize, which made an XtGeometryRequest. You 749N/A * MAY NOT change your geometry from within a SetValues. (Xt man, 749N/A * sect. 9.7.2) So, I factored these changes out. */ 749N/A /* If list is NULL then the list will just be the name of the widget. */ 749N/A /* Get number of items. */ 749N/A /* Get column width. */ 749N/A/* Function Name: ResetList 749N/A * Description: Resets the new list when important things change. 749N/A * Arguments: w - the widget. 749N/A * changex, changey - allow the height or width to change? 749N/A * Returns: TRUE if width or height have been changed 749N/A/* Function Name: ChangeSize. 749N/A * Description: Laysout the widget. 749N/A * Arguments: w - the widget to try change the size of. 749N/A "List Widget: Unknown geometry return.");
749N/A "List Widget: Unknown geometry return.");
749N/A/* Function Name: Initialize 749N/A * Description: Function that initilizes the widget instance. 749N/A * Arguments: junk - NOT USED. 749N/A * new - the new widget. 749N/A * Initialize all private resources. 749N/A /* record for posterity if we are free */ 749N/A /* Set row height. based on font or fontset */ 749N/A/* Function Name: CvtToItem 749N/A * Description: Converts Xcoord to item number of item containing that 749N/A * Arguments: w - the list widget. 749N/A * xloc, yloc - x location, and y location. 749N/A * Returns: the item number. 749N/A /* If out of range, return minimum possible value. */ 749N/A /* If in right margin handle things right. */ 749N/A/* Function Name: FindCornerItems. 749N/A * Description: Find the corners of the rectangle in item space. 749N/A * Arguments: w - the list widget. 749N/A * event - the event structure that has the rectangle it it. 749N/A * ul_ret, lr_ret - the corners ** RETURNED **. 749N/A/* Function Name: ItemInRectangle 749N/A * Description: returns TRUE if the item passed is in the given rectangle. 749N/A * Arguments: w - the list widget. 749N/A * ul, lr - corners of the rectangle in item space. 749N/A * item - item to check. 749N/A * Returns: TRUE if the item passed is in the given rectangle. 749N/A/* HighlightBackground() 749N/A * Paints the color of the background for the given item. It performs 749N/A * simple calculation and probably much faster than using Xlib and a clip mask. 749N/A * x, y - ul corner of the area item occupies. 749N/A * gc - the gc to use to paint this rectangle */ 749N/A /* easy to clip the rectangle by hand and probably alot faster than Xlib */ 749N/A /* Clip the rectangle width and height to the edge of the drawable area */ 749N/A /* Clip the rectangle x and y to the edge of the drawable area */ 749N/A/* ClipToShadowInteriorAndLongest() 749N/A * Converts the passed gc so that any drawing done with that GC will not 749N/A * prevents erasing the shadow. It also clips against the value longest. 749N/A * If the user doesn't set longest, this has no effect (as longest is the 749N/A * maximum of all item lengths). If the user does specify, say, 80 pixel 749N/A * columns, though, this prevents items from overwriting other items. */ 749N/A * paints the name of the item in the appropriate location. 749N/A * item - the item to draw. 749N/A * NOTE: no action taken on an unrealized widget. */ 749N/A /* List's overall width contains the same number of inter-column 749N/A column_space's as columns. There should thus be a half 749N/A column_width margin on each side of each column. 749N/A The row case is symmetric. */ 749N/A * Repaints the widget window on expose events. 749N/A * event - the expose event for this repaint. 749N/A * junk - not used, unless three-d patch enabled. */ 749N/A * This tells the parent what size we would like to be 749N/A * given certain constraints. 749N/A * intended - what the parent intends to do with us. 749N/A * requested - what we want to happen. */ 749N/A * We only care about our height and width. 749N/A * resizes the widget, by changing the number of rows and columns. */ 749N/A "List Widget: Size changed when it shouldn't have when resising.");
749N/A * lays out the item in the list. 749N/A * xfree, yfree - TRUE if we are free to resize the widget in 749N/A * width, height- the is the current width and height that we are going 749N/A * we are going to layout the list widget to, 749N/A * depending on xfree and yfree of course. 749N/A * RETURNS: TRUE if width or height have been changed. */ 749N/A * If force columns is set then always use number of columns specified 749N/A /* 12/3 = 4 and 10/3 = 4, but 9/3 = 3 */ 749N/A /* this counts the same number 749N/A of inter-column column_space 's as columns. There should thus be a 749N/A half column_space margin on each side of each column...*/ 749N/A * If both width and height are free to change the use default_cols 749N/A * to determine the number columns and set new width and height to 749N/A * If the width is fixed then use it to determine the number of columns. 749N/A * If the height is free to move (width still fixed) then resize the height 749N/A * of the widget to fit the current list exactly. 749N/A * The last case is xfree and !yfree we use the height to determine 749N/A * the number of rows and then set the width to just fit the resulting 749N/A * Notifies the user that a button has been pressed, and 749N/A * calls the callback; if the XtNpasteBuffer resource is true 749N/A * then the name of the item is also put in CUT_BUFFER0. */ 749N/A * Find item and if out of range then unhighlight and return. 749N/A * If the current item is unhighlighted then the user has aborted the 749N/A * notify, so unhighlight and return. 749N/A * Call Callback function. 749N/A * unhighlights the current element. */ 749N/A * Highlights the current element. */ 749N/A * Set specified arguments into widget 749N/A /* neither new nor 0, leave it as it was. Not in R5. */ 749N/A /* _DONT_ check for fontset here - it's not in GC.*/ 749N/A /* ...If the above two font(set) change checkers above both failed, check 749N/A if row_space was altered. If one of the above passed, row_height will 749N/A already have been re-calculated. */ 749N/A /* Equiv. fontsets might have different values, but the same fonts, so the 749N/A next comparison is sloppy but not dangerous. */ 749N/A/* Exported Functions */ 749N/A/* Function Name: XawListChange. 749N/A * Description: Changes the list being used and shown. 749N/A * Arguments: w - the list widget. 749N/A * nitems - the number of items in the list. 749N/A * longest - the length (in Pixels) of the longest element 749N/A * resize - if TRUE the the list widget will 749N/A * try to resize itself. 749N/A * NOTE: If nitems of longest are <= 0 then they will be calculated. 749N/A * If nitems is <= 0 then the list needs to be NULL terminated. 749N/A /* If the user passes 0 meaning "calculate it", it must be free */ 749N/A else /* the user's word is god. */ 749N/A /* else - still resize if its not locked */ 749N/A/* Function Name: XawListUnhighlight 749N/A * Description: unlights the current highlighted element. 749N/A * Arguments: w - the widget. 749N/A/* Function Name: XawListHighlight 749N/A * Description: Highlights the given item. 749N/A * Arguments: w - the list widget. 749N/A * item - the item to hightlight. 749N/A/* Function Name: XawListShowCurrent 749N/A * Description: returns the currently highlighted object. 749N/A * Arguments: w - the list widget. 749N/A * Returns: the info about the currently highlighted object.