forked from twitter-archive/twui
/
TUIButton.h
93 lines (70 loc) · 3 KB
/
TUIButton.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
Copyright 2011 Twitter, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this work except in compliance with the License.
You may obtain a copy of the License in the LICENSE file, or at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
TUIButton adopts some baggage from UIButton, probably a mistake
this class is likely to change (be simplified) radically.
*/
#import "TUIControl.h"
#import "TUIGeometry.h"
@class TUIImage;
@class TUILabel;
@class TUIImageView;
typedef enum {
TUIButtonTypeCustom = 0,
} TUIButtonType;
@interface TUIButton : TUIControl
{
NSMutableDictionary *_contentLookup;
TUIEdgeInsets _titleEdgeInsets;
TUIEdgeInsets _imageEdgeInsets;
TUIImageView *_imageView;
TUILabel *_titleView;
NSMenu *popUpMenu;
struct {
unsigned int dimsInBackground:1;
unsigned int buttonType:8;
unsigned int firstDraw:1;
} _buttonFlags;
}
+ (id)buttonWithType:(TUIButtonType)buttonType;
+ (id)button; // custom
@property(nonatomic,assign) TUIEdgeInsets titleEdgeInsets;
@property(nonatomic,assign) TUIEdgeInsets imageEdgeInsets;
@property(nonatomic,assign) BOOL dimsInBackground;
@property(readwrite) BOOL dimsWhenHighlighted;
@property(nonatomic,readonly) TUIButtonType buttonType;
@property (nonatomic, strong) NSMenu *popUpMenu;
@property(nonatomic,readonly,strong) TUILabel *titleLabel;
@property(nonatomic,readonly,strong) TUIImageView *imageView;
- (CGRect)backgroundRectForBounds:(CGRect)bounds;
- (CGRect)contentRectForBounds:(CGRect)bounds;
- (CGRect)titleRectForContentRect:(CGRect)contentRect;
- (CGRect)imageRectForContentRect:(CGRect)contentRect;
@end
@interface TUIButton (Content)
- (void)setTitle:(NSString *)title forState:(TUIControlState)state;
- (void)setTitleColor:(TUIColor *)color forState:(TUIControlState)state;
- (void)setTitleShadowColor:(TUIColor *)color forState:(TUIControlState)state;
- (void)setImage:(TUIImage *)image forState:(TUIControlState)state;
- (void)setBackgroundImage:(TUIImage *)image forState:(TUIControlState)state;
- (NSString *)titleForState:(TUIControlState)state;
- (TUIColor *)titleColorForState:(TUIControlState)state;
- (TUIColor *)titleShadowColorForState:(TUIControlState)state;
- (TUIImage *)imageForState:(TUIControlState)state;
- (TUIImage *)backgroundImageForState:(TUIControlState)state;
@property(nonatomic,readonly,retain) NSString *currentTitle;
@property(nonatomic,readonly,retain) TUIColor *currentTitleColor;
@property(nonatomic,readonly,retain) TUIColor *currentTitleShadowColor;
@property(nonatomic,readonly,retain) TUIImage *currentImage;
@property(nonatomic,readonly,retain) TUIImage *currentBackgroundImage;
@end