public
Description: A Cocoa View to draw Annotated Pinyin above Hanzi text
Homepage:
Clone URL: git://github.com/jjgod/pinyinview.git
pinyinview / PYView.h
100644 63 lines (46 sloc) 1.396 kb
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
// PYView.h: Public Interface for PinyinView
 
#import <Cocoa/Cocoa.h>
 
// The resulting font size for pinyin text is
// font size for hanzi * kPinyinFontSizeRatio
#define kPinyinFontSizeRatio 0.35
 
// Border length in user space unit
#define kPinyinViewBorder 10
 
// The height between pinyin and hanzi
#define kPinyinHanziLeading 10
 
// The advance space ratio for hanzi
#define kFontAdvanceRatio 1.1
 
// The initial capacity of PYMarkerItem array
#define kMarkerItemsInitialCapacity 10
 
// The space between each marker item
#define kMarkerItemInterspacing 20
 
@interface PYMarkerItem : NSObject
{
    NSString *_han;
    NSArray *_py;
    int _type;
}
 
- (NSString *) hanzi;
- (NSArray *) pinyin;
- (int) type;
 
- (id) initWithHanzi: (NSString *) hanzi
              pinyin: (NSArray *) pinyin
                type: (int) type;
 
+ (id) itemWithHanzi: (NSString *) hanzi
              pinyin: (NSArray *) pinyin
                type: (int) type;
 
@end
 
@interface PYView : NSView
{
    NSMutableArray *_items;
    NSDictionary *_hanAttributes;
    NSDictionary *_pyAttributes;
    float _size;
    float _pinyinSize;
    float _advance;
}
 
- (void) appendMarkerItem: (PYMarkerItem *) item;
- (void) clearMarkerItems;
 
- (id) initWithFrame: (NSRect) frameRect
            fontName: (NSString *) name
               color: (NSColor *) color;
 
@end