Up

# GSHbox

### Authors

Nicola Pero (`n.pero@mi.flashnet.it`)

Date: Generated at 2026-02-17 21:02:56 +0000

> The GSHbox class (a GNU extension)

Copyright: (C) 1999-2010 Free Software Foundation, Inc.

# Software documentation for the GSHbox class

## GSHbox : GSTable

> Declared in:
>   GNUstepGUI/GSHbox.h

Availability: OpenStep
Description forthcoming.

Instance Variables

### Method summary

- -addSeparator
- -addSeparatorWithMinXMargin:
- -addView:
- -addView:enablingXResizing:
- -addView:enablingXResizing:withMinXMargin:
- -addView:withMinXMargin:
- -init
- -numberOfViews
- -setDefaultMinXMargin:

### addSeparator

- (void) addSeparator;
Availability: OpenStep
Add a separator with the default MinXMargin.

### addSeparatorWithMinXMargin:

- (void) addSeparatorWithMinXMargin: (float)aMargin;
Availability: OpenStep
Add a separator (a vertical groove line encompassing all the height of the GSHbox) to the GSHbox, inserting a margin aMargin between the separator and the last added view.

### addView:

- (void) addView: (NSView*)aView;
Availability: OpenStep
See -addView:enablingXResizing:withMinXMargin:

### addView: enablingXResizing:

- (void) addView: (NSView*)aView enablingXResizing: (BOOL)aFlag;
Availability: OpenStep
See -addView:enablingXResizing:withMinXMargin:

### addView: enablingXResizing: withMinXMargin:

- (void) addView: (NSView*)aView enablingXResizing: (BOOL)aFlag withMinXMargin: (float)aMargin;
Availability: OpenStep

Pack views in the GSHbox. Don't use the corresponding methods of GSTable, which are far more general and far more complicate. If you need to do that, use GSTable instead.

Add a view to the box, enabling X Resizing only if flag is `YES`, and a MinXMargin aMargin. If aFlag is `YES` the [view and its margins] should be resized in the horizontal direction when the GSHbox is resized in the horizontal direction. If aFlag is `NO` the view is never X-resized and always left in its original width. The default is `YES`.

The min X margin is used to separate the view from the preceding one. The first view added to the box has no min X margin; if you try setting one for it, it is ignored (zero is used instead).

When views are added to the GSHbox, it might happen that some of the added views have a greater height than others. When this happens, the GSHbox resizes all the views to the highest height. As usual, each view is resized with its margins; the effect of the resizing on each view is determined by the autoresizing mask of the view. The classical options are

(NSViewMinYMargin | NSViewMaxYMargin)
  Center the view vertically
NSViewMinYMargin
  Flush the view up (down if the GSHbox is flipped)
NSViewMaxYMargin
  Flush the view down (up if the GSHbox is flipped)
NSViewHeightSizable
  Expand the view to the whole height

(you may need to OR these masks with the mask you use in the horizontal direction, if you use any).

With a GSHbox, only one margin is set when you add views to the GSHbox: the margin between each view and the preceding one. Exception: the first view is special, and has no margin set (it has no preceding view to be separated from). Space above or below the view may result if the view is shorter, in the vertical direction, than the other views in the GSHbox; in that case the view is resized to fit vertically, according to its autoresizingMask. By changing the autoresizingMask you may decide whether the space should go to the view or to its vertical margins; this for example lets you center vertically or flush up/down your view.

### addView: withMinXMargin:

- (void) addView: (NSView*)aView withMinXMargin: (float)aMargin;
Availability: OpenStep
See -addView:enablingXResizing:withMinXMargin:

### init

- (id) init;
Availability: OpenStep
Always use init for GSHbox: other methods don't make sense. Don't used GSTable methods. You do not need to specify the number of views you plan to put in the box when you initialize it.

### numberOfViews

- (int) numberOfViews;
Availability: OpenStep
Return the number of views in the GSHbox (separators included).

### setDefaultMinXMargin:

- (void) setDefaultMinXMargin: (float)aMargin;
Availability: OpenStep
Use only the following method to set a default margin. The default margin set with the following method will be used for all the views added after. (Exception: the first view put in the box has no margins at all) It will not affect already added views. In a GSHbox, only one margin is used, the one between each view and the preceding one. If what you want is space around the GSHbox, you don't want a margin but a border; use setBorder: (see GSTable, "Setting Border"). If you need more complicated margins/borders, use GSTable.

## Instance Variables for GSHbox Class

### _defaultMinXMargin

@protected float _defaultMinXMargin;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _haveViews

@protected BOOL _haveViews;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

Up