Table Geometry Management Widget for the X Toolkit David Harrison UC Berkeley Electronics Research Lab davidh ic Berkeley EDU ucbvax ucbcad davidh Table is a composite widget designed to manage the size and location of its children The widget uses an array model to simplify the arrangement of child widgets The widget is directly derived from the core and composite widgets provided by the X Toolkit and can be used with any widget set It has been tested using the Athena widget set Below is a short summary on the operation and use of the Table widget It assumes a working knowledge of the X Toolkit Intrinsics The Table widget addresses formatting for dialog boxes Dialog boxes are rectangular windows that contain a wide variety of widgets Most dialog boxes are arranged with widgets aligned in a way similar to the layout found in business forms The Table widget is designed to make such layouts easy to specify When designing dialog boxes that resemble business forms the primary problem is specifying the alignment between widgets The Table widget addresses this problem by adopting an array model Under this model widgets are placed at row and column locations in a variable sized array Widgets may span more than one row or column The array can expand or contract in size as needed There are options to control justification and place size restrictions on rows and columns of widgets The Table widget can contain any number and type of sub widgets including other Table widgets XtCreateWidget is used to create new Table widgets using the class variable tableWidgetClass The resources listed below are retrieved from the argument list or from the resource database tableWidgetClass Name Type Default Description XtNbackground Pixel XtDefaultBackground Window background XtNborder Pixel XtDefaultForeground Window border XtNborderWidth Dimension 0 Width of border XtNcursor Cursor Cursor None XtNx Position 0 X position of table XtNy Position 0 Y position of table XtNwidth Dimension computed at realize Width of form XtNheight Dimension computed at realize Height of form XtNmappedWhenManaged Boolean True XtMapWidget is automatic XtNsensitive Boolean True Widget receives input XtNlayout Layout None See text XtNinternalHeight Dimension 0 Int horizontal padding XtNinternalWidth Dimension 0 Int vertical padding XtNcolumnSpacing Dimension 0 Inter column padding XtNrowSpacing Dimension 0 Inter row padding XtNdefaultOptions Options None See text Widgets are added to a Table by specifying a Table widget as the parent widget when the widget is created Once a widget is added to a table it can be assigned a row and column position a horizontal and vertical span and justification options This information can be specified in two ways using public access functions or using the resource database Public access functions allow the programmer to dynamically alter the formatting of children of a Table widget One can alter the position span or options of a widget using XtTblConfig void XtTblConfig Widget w Position col Position row Dimension h span Dimension v span XtTblMask opt Subwidget to modify Column position horizontal Row position vertical How many columns to span How many rows to span Justification options The specified widget which must be a child of a Table widget will be placed at column col and row row The widget will span h span columns to the right of col and v span rows below row The array for the table will expand as necessary Options are specified by or ing together the following option bits TBL LEFT TBL RIGHT TBL TOP TBL BOTTOM TBL LK WIDTH TBL LK HEIGHT TBL SM WIDTH TBL SM HEIGHT Horizontally left justified Horizontally right justified Vertically top justified Vertically bottom justified Don t try to expand the widget horizontally Don t try to expand the widget vertically Force the width to be as small as possible Force the height to be as small as possible Alternatively if options is equal to TBL DEF OPT the options are set to the default options for the Table widget The default options for the Table widget are set using the XtNdefaultOptions resource see resource specifications below The routine changes the formatting information in its internal table If the Table widget is realized the positions of all child widgets are recomputed and the change on the screen will be immediate The Table widget computes the size of a widget based on the minimum size required for the row s and column s it occupies However some widgets may require less space than that computed by the Table widget In this case the widget is aligned in the larger space according to the bits TBL LEFT TBL RIGHT TBL TOP and TBL BOTTOM These bits may be combined i e TBL RIGHT TBL TOP specifies upper right hand corner justification If no justification bits are specified the widget is centered Some widgets may be amenable to growing to any size specified by the Table widget Often it may be desirable to force these widgets to remain at their optimal size for asthetic or operational convenience If the TBL LK WIDTH bit is specified the Table widget will not make the widget any wider than it s original desired size Similarly if the TBL LK HEIGHT bit is specified the Table widget will not make the widget any taller than it s original size Note this may bring widget justification into play When a Table widget is resized it automatically recomputes the sizes of the rows and columns of an array and distributes extra space evenly among the rows and columns Often it may be useful to control this distribution of space so that some rows or columns are not resized when extra space becomes available If the TBL SM WIDTH bit is specified the entire column s containing the widget are excluded from the excess space distribution algorithm Thus the column s are forced to remain as small as possible The TBL SM HEIGHT bit works the same way with respect to the row s containing the widget A title bar is a good example of this concept When a dialog is resized any excess vertical space should be given to the body of the dialog not to the title bar Thus TBL SM HEIGHT would be specified for a title bar widget In most applications the programmer will not set all of the above information for all widgets The following convenience functions have been defined for use in these cases void XtTblPosition Widget w Child of table widget Position col Column position horizontal Position row Row position vertical The specified widget which must be a child of a Table widget will be
View Full Document
Unlocking...