SgGrid(3X)
SgGrid - The SgGrid widget class
As shipped in IRIX 6.5. First release of IRIX 6.5.
NAME SgGrid - The SgGrid widget class SYNOPSIS #include <Sgm/Grid.h> VERSION This page documents the version of Sgm that accompanies Motif 1.2. DESCRIPTION SgGrid is a container widget with no input semantics of its own. It arranges its children in a two dimensional grid of arbitrary size. Each row and column of this grid may be separately designated as having a fixed size or as having some degree of stretchability. In addition, each child may be resizable in either or both directions, or forced to a fixed size. If a child is a fixed size, and smaller than the cell that contains it, the childs position within the cell is determined by an XmNgravity resource. Following are some important considerations in using an SgGrid widget: The position of each child must be set using the XmNrow and XmNcolumn resources. If no position is specified, the child will be placed in an unspecified free cell. The resizability of each row and column must be set using convenience functions SgGridSetRowResize and SgGridSetColumnResize. The default is for all rows and columns to be resizable. All widgets are resized according to their relative natural size. Unmapping a child has no effect on the SgGrid except that the child is not mapped. EXAMPLES The following example creates a grid of four buttons that all size (and resize) equally to fill one quarter of their parent. createGrid(Widget parent) { int n; Arg args[10]; Widget grid, child1, child2, child3, child4; n = 0; XtSetArg(args[n], XmNnumRows, 2); n++; XtSetArg(args[n], XmNnumColumns, 2); n++; grid = SgCreateGrid( parent, "grid", args, n ); child1 = XtVaCreateManagedWidget( "child1", xmPushButtonWidgetClass, grid, XmNrow, 0, XmNcolumn, 0, NULL ); child2 = XtVaCreateManagedWidget( "child2", xmPushButtonWidgetClass, grid, XmNrow, 0, XmNcolumn, 1, NULL ); child3 = XtVaCreateManagedWidget( "child3", xmPushButtonWidgetClass, grid, XmNrow, 1, XmNcolumn, 0, NULL ); child4 = XtVaCreateManagedWidget( "child4", xmPushButtonWidgetClass, grid, XmNrow, 1, XmNcolumn, 1, NULL ); XtManageChild(grid); } The following example creates four buttons. The top row has a fixed vertical size, while the bottom row is resizable. The left column has a fixed size, but the right column can be resized. The button in the lower right can be resized, but the others cannot. The button in the lower left cell, which can be resized vertically, floats in the middle of its cell. The button in the upper right stays to the left of its cell. createGrid(Widget parent) { int n; Arg args[10]; Widget grid, chidl1, child2, child3, child4; n = 0; XtSetArg(args[n], XmNnumRows, 2); n++; XtSetArg(args[n], XmNnumColumns, 2); n++; grid = SgCreateGrid( parent, "grid", args, n ); SgGridSetColumnResizability(grid, 0, 0); SgGridSetRowResizability(grid, 0, 0); child1 = XtVaCreateManagedWidget( "child1", xmPushButtonWidgetClass, grid, XmNrow, 0, XmNcolumn, 0, NULL ); child2 = XtVaCreateManagedWidget( "child2", xmPushButtonWidgetClass, grid, XmNrow, 0, XmNcolumn, 1, XmNresizeHorizontal, FALSE, XmNgravity, WestGravity, NULL ); child3 = XtVaCreateManagedWidget( "child3", xmPushButtonWidgetClass, grid, XmNrow, 1, XmNcolumn, 0, XmNresizeVertical, FALSE, XmNgravity, CenterGravity, NULL ); child4 = XtVaCreateManagedWidget( "child4", xmPushButtonWidgetClass, grid, XmNrow, 1, XmNcolumn, 1, NULL ); XtManageChild(grid); } This creates an initial layout like the following. The "*"'s are the boundaries of each cell in the grid, while the "-"'s are the sides of the button widgets. ******************************** * -------------*---------------* * | |*| |* * | Button1 |*| Button2 |* * | |*| |* * |-----------|*--------------|* * ****************************** * |-----------|*--------------|* * | |*| |* * | Button3 |*| Button4 |* * | |*| |* * -------------*---------------* ******************************** When resized to be larger, this window will appear as follows: ****************************************** *--------------*--------------- * *| |*| | * *| Button1 |*| Button2 | * *| |*| | * *|------------|*--------------| * ****************************************** * |*------------------------|* * |*| |* * |*| |* * |*| |* *|------------|*| |* *| |*| |* *| Button3 |*| Button4 |* *| |*| |* *|------------|*| |* * |*| |* * |*| |* * |*| |* * *-------------------------* ****************************************** Classes SgGrid inherits behavior and resources from Core, Composite, Constraint, XmManager, and XmBulletinBoard classes. The class pointer is sgGridWidgetClass. The class name is SgGrid. New Resources The following table defines a set of widget resources used by the programmer to specify data. The programmer can also set the resource values for the inherited classes to set attributes for this widget. To reference a resource by name or by class in a .Xdefaults file, remove the XmN or XmC prefix and use the remaining letters. To specify one of the defined values for a resource in a .Xdefaults file, remove the Xm prefix and use the remaining letters (in either lowercase or uppercase, but include any underscores between words). The codes in the access column indicate if the given resource can be set at creation time (C), set by using XtSetValues (S), retrieved by using XtGetValues (G), or is not applicable (N/A). ______________________________________________________________________ | SgGrid Resource Set | |__________________|___________________|___________|_________|________| | Name | Class | Type | Default| Access| |__________________|___________________|___________|_________|________| |__________________|___________________|___________|_________|________| | XmNnumRows | XmCNumRows | int | 1 | CG | |__________________|___________________|___________|_________|________| | XmNnumColumns | XmCNumColumns | int | 1 | CG | |__________________|___________________|___________|_________|________| |____|_____________|______|____________|________|__|______|__|________| | | | XmN|howGrid | XmCS|owGrid | Boolea| | FALS| | CSG | | | |____|_____________|______|____________|________|__|______|__|________| | | | XmN|utoLayout | XmCA|toLayout | Boolea| | TRUE| | CSG | | | |____|_____________|______|____________|________|__|______|__|________| | | | XmN|efaultSpacing| XmCD|faultSpacing| Dimens|on| 4 | | CSG | | | |____|_____________|______|____________|________|__|______|__|________| | | | | | | | | X|NnumRows | | | | | | Specifies the n|mber of rows in the g|id. This |esource | | | must be specifi|d at widget creation |ime. The |efault | | | is 1. | | | | | | | | | | | | | | | | | X|NnumColumns | | | | | | Specifies the n|mber of columns in th| grid. Th|s | | | resource must b| specified at widget |reation t|me. The | | | default is 1. | | | | | | | | | | | | | | | | | X|NshowGrid | | | | | | When TRUE, the |gGrid widget visibly |isplays t|e | | | boundaries of e|ch cell in the grid. |his can b| useful | | | for debugging r|size specifications. |he defaul| is | | | FALSE. | | | | | | | | | | | | | | | | | X|NautoLayout | | | | | | When TRUE (the |efault), all rows or |olumns th|t have | | | a non-zero resi|ability are sized acc|rding to |he | | | desired natural|size of the widgets i| that row|or | | | column. If this|resource is FALSE, al| widgets |n | | | resizable rows |r columns are sized a|cording t| a | | | relative resiza|ility factor (see | | | | | SgGridSetRowRes|zability and | | | | | SgGridSetColumn|esizability, below). |y default| this | | | factor is "1" f|r all widgets, leadin| to an eq|al | | | sizing strategy| | | | | | | | | | | | | | | | | X|NdefaultLayout | | | | | | Specifies a def|ult spacing between r|ws and co|umns. | | | This value can |e overriden on a per |ow/column|basis | | | using SgGridSet|olumnMargin or SgGrid|etRowMarg|n. | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |____________________|_____________________|_________|__________________|________| _________________________________________________________________________________ | SgGrid Constraint Resource Set | |____________________|_____________________|_________|__________________|________| | Name | Class | Type | Default | Access| |____________________|_____________________|_________|__________________|________| |____________________|_____________________|_________|__________________|________| | XmNgravity | XmCGravity | int | NorthWestGravity| CSG | |____________________|_____________________|_________|__________________|________| | XmNresizeVertical | XmCResizeVertical | Boolean| TRUE | CSG | |____________________|_____________________|_________|__________________|________| | XmNresizeHorizontal| XmCResizeHorizontal| Boolean| TRUE | CSG | |____________________|_____________________|_________|__________________|________| | XmNrow | XmCRow | int | dynamic | CSG | |____________________|_____________________|_________|__________________|________| | XmNcolumn | XmCColumn | int | dynamic | CSG | |____________________|_____________________|_________|__________________|________| XmNgravity If a child widget is not resizable, and is smaller than the cell that contains it, the child's gravity controls its position within the cell. Gravity may be any of the gravity values defined by Xlib except StaticGravity and ForgetGravity. The default is NorthWestGravity; Note that gravity has no effect is both verticalResize and horizontalResize are TRUE. XmNresizeVertical If TRUE, the child will be resized to fill the cell containing it in the vertical direction. The default is TRUE; XmNresizeHorizontal If TRUE, the child will be resized to fill the cell containing it in the horizontal direction. The default is TRUE; XmNrow Determines the row of the grid in which the child is placed. If no row is specified, the child will be placed in a cell randomly selected from those not currently occupied. XmNcolumn Determines the column of the grid in which the child is placed. If no row is specified, the child will be placed in a cell randomly selected from those not currently occupied. Grid Functions SgGridSetRowResizability(widget, row, factor ) Widget widget ; int row; int factor; Set the degree to which the specified row can be resized. The default is a value of 1 for all rows, which means that all rows will be equally resizable, if the value of XmNautoLayout is false. Setting this value to 0 establishes the specified row as not resizable, regardless of the setting of XmNautoLayout. Other values are taken relative to all other rows. For example, if an SgGrid widget has three rows, whose resize factors are set to 100, 100, and 200, the first and second rows will occupy 1/4 (computed as: 100/(100+100+200)) of the space, while the the third row will occupy one half of the available space. SgGridSetColumnResizability( widget, col, factor ) Widget widget ; int col; int factor; This function sets the resizability of individual columns, and works in a similar fashion as SgGridSetRowResizability. SgGridSetRowMargin(widget, row, margin ) Widget widget ; int row; Dimension margin; Set the margin height of the specified row. Each row and column can have a margin between it's edge and the widgets the row or column contains. The margin is added to both sides of each row or column, so adding a 1 pixel marign grows the relevant dimension of the affected row or column by 2 pixels. SgGridSetColumnMargin( widget, col, margin ) Widget widget ; int col; Dimension margin; Set the margin width of the specified column. Inherited Resources SgGrid inherits behavior and resources from the following superclasses. For a complete description of each resource, refer to the man page for that superclass. ___________________________________________________________________________________ | XmBulletinBoard Resource Set | |____________________|____________________|________________|______________|________| | Name | Class | Type | Default | Access| |____________________|____________________|________________|______________|________| |____________________|____________________|________________|______________|________| | XmNallowOverlap | XmCAllowOverlap | Boolean | True | CSG | |____________________|____________________|________________|______________|________| | XmNautoUnmanage | XmCAutoUnmanage | Boolean | True | CG | |____________________|____________________|________________|______________|________| | XmNbuttonFontList | XmCButtonFontList | XmFontList | dynamic | CSG | |____________________|____________________|________________|______________|________| | XmNcancelButton | XmCWidget | Widget | NULL | SG | |____________________|____________________|________________|______________|________| | XmNdefaultButton | XmCWidget | Widget | NULL | SG | |____________________|____________________|________________|______________|________| | XmNdefaultPosition | XmCDefaultPosition| Boolean | True | CSG | |____________________|____________________|________________|______________|________| | XmNdialogStyle | XmCDialogStyle | unsigned char | dynamic | CSG | |____________________|____________________|________________|______________|________| | XmNdialogTitle | XmCDialogTitle | XmString | NULL | CSG | |____________________|____________________|________________|______________|________| | XmNfocusCallback | XmCCallback | XtCallbackList| NULL | C | |____________________|____________________|________________|______________|________| | XmNlabelFontList | XmCLabelFontList | XmFontList | dynamic | CSG | |____________________|____________________|________________|______________|________| | XmNmapCallback | XmCCallback | XtCallbackList| NULL | C | |____________________|____________________|________________|______________|________| | XmNmarginHeight | XmCMarginHeight | Dimension | 0 | CSG | |____________________|____________________|________________|______________|________| | XmNmarginWidth | XmCMarginWidth | Dimension | 0 | CSG | |____________________|____________________|________________|______________|________| | XmNnoResize | XmCNoResize | Boolean | False | CSG | |____________________|____________________|________________|______________|________| | XmNresizePolicy | XmCResizePolicy | unsigned char | XmRESIZE_ANY| CSG | |____________________|____________________|________________|______________|________| | XmNshadowType | XmCShadowType | unsigned char | XmSHADOW_OUT| CSG | |____________________|____________________|________________|______________|________| | XmNtextFontList | XmCTextFontList | XmFontList | dynamic | CSG | |____________________|____________________|________________|______________|________| | XmNtextTranslations| XmCTranslations | XtTranslations| NULL | C | |____________________|____________________|________________|______________|________| | XmNunmapCallback | XmCCallback | XtCallbackList| NULL | C | |____________________|____________________|________________|______________|________| _________________________________________________________________________________________________________ | XmManager Resource Set | |______________________|_____________________________|___________________|______________________|________| | Name | Class | Type | Default | Access| |______________________|_____________________________|___________________|______________________|________| |______________________|_____________________________|___________________|______________________|________| | XmNbottomShadowColor | XmCBottomShadowColor | Pixel | dynamic | CSG | |______________________|_____________________________|___________________|______________________|________| | XmNbottomShadowPixmap| XmCBottomShadowPixmap | Pixmap | XmUNSPECIFIED_PIXMAP| CSG | |______________________|_____________________________|___________________|______________________|________| | XmNforeground | XmCForeground | Pixel | dynamic | CSG | |______________________|_____________________________|___________________|______________________|________| | XmNhelpCallback | XmCCallback | XtCallbackList | NULL | C | |______________________|_____________________________|___________________|______________________|________| | XmNhighlightColor | XmCHighlightColor | Pixel | dynamic | CSG | |______________________|_____________________________|___________________|______________________|________| | XmNhighlightPixmap | XmCHighlightPixmap | Pixmap | dynamic | CSG | |______________________|_____________________________|___________________|______________________|________| | XmNinitialFocus | XmCInitialFocus | Widget | dynamic | CSG | |______________________|_____________________________|___________________|______________________|________| | XmNnavigationType | XmCNavigationType | XmNavigationType | XmTAB_GROUP | CSG | |______________________|_____________________________|___________________|______________________|________| | XmNshadowThickness | XmCShadowThickness | Dimension | dynamic | CSG | |______________________|_____________________________|___________________|______________________|________| | XmNstringDirection | XmCStringDirection | XmStringDirection| dynamic | CG | |______________________|_____________________________|___________________|______________________|________| | XmNtopShadowColor | XmCBackgroundTopShadowColor| Pixel | dynamic | CSG | |______________________|_____________________________|___________________|______________________|________| | XmNtopShadowPixmap | XmCTopShadowPixmap | Pixmap | dynamic | CSG | |______________________|_____________________________|___________________|______________________|________| | XmNtraversalOn | XmCTraversalOn | Boolean | True | CSG | |______________________|_____________________________|___________________|______________________|________| | XmNunitType | XmCUnitType | unsigned char | dynamic | CSG | |______________________|_____________________________|___________________|______________________|________| | XmNuserData | XmCUserData | Pointer | NULL | CSG | |______________________|_____________________________|___________________|______________________|________| ________________________________________________________________________ | Composite Resource Set | |__________________|___________________|_____________|_________|________| | Name | Class | Type | Default| Access| |__________________|___________________|_____________|_________|________| |__________________|___________________|_____________|_________|________| | XmNchildren | XmCReadOnly | WidgetList | NULL | G | |__________________|___________________|_____________|_________|________| | XmNinsertPosition| XmCInsertPosition| XtOrderProc| NULL | CSG | |__________________|___________________|_____________|_________|________| | XmNnumChildren | XmCReadOnly | Cardinal | 0 | G | |__________________|___________________|_____________|_________|________| ________________________________________________________________________________________________________________ | Core Resource Set | |______________________________|_______________________________|________________|______________________|________| | Name | Class | Type | Default | Access| |______________________________|_______________________________|________________|______________________|________| |______________________________|_______________________________|________________|______________________|________| | XmNaccelerators | XmCAccelerators | XtAccelerators| dynamic | N/A | |______________________________|_______________________________|________________|______________________|________| | XmNancestorSensitive | XmCSensitive | Boolean | dynamic | G | |______________________________|_______________________________|________________|______________________|________| | XmNbackground | XmCBackground | Pixel | dynamic | CSG | |______________________________|_______________________________|________________|______________________|________| | XmNbackgroundPixmap | XmCPixmap | Pixmap | XmUNSPECIFIED_PIXMAP| CSG | |______________________________|_______________________________|________________|______________________|________| | XmNborderColor | XmCBorderColor | Pixel | XtDefaultForeground | CSG | |______________________________|_______________________________|________________|______________________|________| | XmNborderPixmap | XmCPixmap | Pixmap | XmUNSPECIFIED_PIXMAP| CSG | |______________________________|_______________________________|________________|______________________|________| | XmNborderWidth | XmCBorderWidth | Dimension | 0 | CSG | |______________________________|_______________________________|________________|______________________|________| | XmNcolormap | XmCColormap | Colormap | dynamic | CG | |______________________________|_______________________________|________________|______________________|________| | XmNdepth | XmCDepth | int | dynamic | CG | |______________________________|_______________________________|________________|______________________|________| | XmNdestroyCallback | XmCCallback | XtCallbackList| NULL | C | |______________________________|_______________________________|________________|______________________|________| | XmNheight | XmCHeight | Dimension | dynamic | CSG | |______________________________|_______________________________|________________|______________________|________| | XmNinitialResourcesPersistent| XmCInitialResourcesPersistent| Boolean | True | C | |______________________________|_______________________________|________________|______________________|________| | XmNmappedWhenManaged | XmCMappedWhenManaged | Boolean | True | CSG | |______________________________|_______________________________|________________|______________________|________| | XmNscreen | XmCScreen | Screen * | dynamic | CG | |______________________________|_______________________________|________________|______________________|________| | XmNsensitive | XmCSensitive | Boolean | True | CSG | |______________________________|_______________________________|________________|______________________|________| | XmNtranslations | XmCTranslations | XtTranslations| dynamic | CSG | |______________________________|_______________________________|________________|______________________|________| | XmNwidth | XmCWidth | Dimension | dynamic | CSG | |______________________________|_______________________________|________________|______________________|________| | XmNx | XmCPosition | Position | 0 | CSG | |______________________________|_______________________________|________________|______________________|________| | XmNy | XmCPosition | Position | 0 | CSG | |______________________________|_______________________________|________________|______________________|________| Translations SgGrid inherits translations from XmBulletinBoard. RELATED INFORMATION Composite(3X), Constraint(3X), Core(3X), XmBulletinBoard(3X), SgCreateGrid, SgCreateGridDialog(3X), and XmManager(3X).