-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSSYLabelledRadioButtons.h
executable file
·78 lines (62 loc) · 2.7 KB
/
SSYLabelledRadioButtons.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#import <Cocoa/Cocoa.h>
/*!
@brief This class provides a control which consists of a non-editable NSTextField
<i>label</i> and, below it, an NSMatrix of radio buttons in a single column.
@details May be used, for example for a user to select <i>Favorite Color</i>, <i>Gender</i>,
etc. etc.
Under the hood, uses NSTextFields to provide the text of each cell in the
NSMatrix of radio buttons. This allows text to wrap. Cell spacing will
expand as required to fit the cell with the most text height.
*/
@interface SSYLabelledRadioButtons : NSView {
BOOL firstDrawing ;
// If you select an NSMatrix' cell too early, it won't work for some reason.
// In drawRect:, it works. So, I override -drawRect: to select th3
// "preselected" cell. Note: In a 1x3 matrix, if not set, it selects the middle cell.
// Possibly this is a problem/bug?
NSInteger preselectedIndex ;
CGFloat m_width ;
NSArray* m_choices ;
}
@property (assign) CGFloat width ;
/*!
@brief Convenience method for getting an autoreleased instance of this class.
@param label The text value of the <i>label</i> which will appear above
the matrix in the returned instance. May be nil if you don't want a label.
@param choices An array of strings giving the localized names of the choices
to appear in the matrix.
@param width The width that the returned view will be.
@result The instance, autoreleased
*/
+ (SSYLabelledRadioButtons*)radioButtonsWithLabel:(NSString*)label
choices:(NSArray*)choices
width:(CGFloat)width ;
/*!
@brief The index of the row selected in the receiver's matrix button.
@details Use this method if you want to pre-select a cell, instead of
accessing the matrix and sending it -selectCell. The reason is that
if you select the cell too early, it won't work for some reason,
possibly a bug in Cocoa? This accessor uses a little work-around
under the hood.
If selectedIndex is not set, it defaults to 0.
*/
@property NSInteger selectedIndex ;
/*!
@brief The receivers choices which were set during initialization
*/
@property (retain, readonly) NSArray* choices ;
/*!
@brief Resizes the height of the receiver to accomodate the its current values,
subject to allowsShrinking
@param allowShrinking YES if the height is allowed to be reduced. If this parameter
is NO, and less height than the current height is required, this invocation will not reduce
the height but will instead leave empty space.
*/
- (void)sizeHeightToFitAllowShrinking:(BOOL)allowShrinking ;
/*!
@brief Changes the height of the receiver and its subviews as
required to accomodate the cells' texts and the receiver's
current maxWidth
*/
- (void)sizeToFit ;
@end