<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,2 +1,3 @@
 */build
 *.pbxuser
+*.perspectivev3</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -15,6 +15,12 @@
 // 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;
@@ -30,19 +36,25 @@
               pinyin: (NSArray *) pinyin
                 type: (int) type;
 
++ (id) itemWithHanzi: (NSString *) hanzi
+              pinyin: (NSArray *) pinyin
+                type: (int) type;
+
 @end
 
 @interface PYView : NSView
 {
-    PYMarkerItem *_item;
-    NSDictionary *_hanAttributes;
-    NSDictionary *_pyAttributes;
-    float         _size;
-    float         _pinyinSize;
-    float         _advance;
+    NSMutableArray *_items;
+    NSDictionary   *_hanAttributes;
+    NSDictionary   *_pyAttributes;
+    float           _size;
+    float           _pinyinSize;
+    float           _advance;
 }
 
-- (void) setMarkerItem: (PYMarkerItem *) item;
+- (void) appendMarkerItem: (PYMarkerItem *) item;
+- (void) clearMarkerItems;
+
 - (id) initWithFrame: (NSRect) frameRect
             fontName: (NSString *) name
                color: (NSColor *) color;</diff>
      <filename>PYView.h</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,15 @@
 
 @implementation PYMarkerItem
 
++ (id) itemWithHanzi: (NSString *) hanzi
+              pinyin: (NSArray *) pinyin
+                type: (int) type
+{
+    return [[[PYMarkerItem alloc] initWithHanzi: hanzi
+                                         pinyin: pinyin
+                                           type: type] autorelease];
+}
+
 - (id) initWithHanzi: (NSString *) hanzi
               pinyin: (NSArray *) pinyin
                 type: (int) type
@@ -15,7 +24,7 @@
     {
         _han = [hanzi retain];
         _py  = [pinyin retain];
-        type = type;
+        _type = type;
     }
 
     return self;
@@ -60,8 +69,6 @@
                       kPinyinHanziLeading) / (1 + kPinyinFontSizeRatio);
         _advance = size * kFontAdvanceRatio;
 
-        NSLog(@&quot;size = %g&quot;, size);
-
         NSDictionary *fontAttributes = 
             [NSDictionary dictionaryWithObjectsAndKeys: 
                 name, NSFontNameAttribute, 
@@ -90,56 +97,75 @@
         _size = size;
         // Relax for a few more pixels
         _pinyinSize = kPinyinFontSizeRatio * size + 3;
+
+        _items = [[NSMutableArray alloc] initWithCapacity: kMarkerItemsInitialCapacity];
     }
-    
+
     return self;
 }
 
-- (void) drawRect: (NSRect) rect
+- (float) drawItem: (PYMarkerItem *) item
+           atPoint: (NSPoint) point
 {
-    [[NSColor blackColor] set];
-    NSRectFill(rect);
+    NSString *hanzi = [item hanzi];
 
-    if (_item &amp;&amp; [_item hanzi])
-    {
-        NSString *hanzi = [_item hanzi];
-
-        [hanzi drawAtPoint: NSMakePoint(kPinyinViewBorder, kPinyinViewBorder) 
-            withAttributes: _hanAttributes];
+    [hanzi drawAtPoint: point
+        withAttributes: _hanAttributes];
 
-        NSArray *pinyin = [_item pinyin];
+    NSArray *pinyin = [item pinyin];
 
-        if (pinyin)
-        {
-            NSEnumerator *enumerator = [pinyin objectEnumerator];
-            NSString *py;
+    float x = point.x;
+    float y = point.y + _size + kPinyinHanziLeading;
 
-            float y = kPinyinViewBorder + _size + kPinyinHanziLeading;
-            float x = kPinyinViewBorder;
+    if (pinyin)
+    {
+        NSEnumerator *enumerator = [pinyin objectEnumerator];
+        NSString *py;
 
-            while (py = [enumerator nextObject])
-            {
-                // Center the pinyin
-                float shift = (_advance - [py sizeWithAttributes: _pyAttributes].width) / 2;
+        while (py = [enumerator nextObject])
+        {
+            // Center the pinyin
+            float shift = (_advance - [py sizeWithAttributes: _pyAttributes].width) / 2;
 
-                [py drawAtPoint: NSMakePoint(x + shift, y)
-                 withAttributes: _pyAttributes];
+            [py drawAtPoint: NSMakePoint(x + shift, y)
+             withAttributes: _pyAttributes];
 
-                x += _advance;
-            }
+            x += _advance;
         }
     }
+
+    return x;
+}
+
+- (void) drawRect: (NSRect) rect
+{
+    [[NSColor blackColor] set];
+    NSRectFill(rect);
+
+    NSEnumerator *enumerator = [_items objectEnumerator];
+    PYMarkerItem *item;
+
+    NSPoint p = NSMakePoint(kPinyinViewBorder,
+                            kPinyinViewBorder);
+
+    while (item = [enumerator nextObject])
+        if ([item type] == 1)
+            p.x = [self drawItem: item atPoint: p] + kMarkerItemInterspacing;
+}
+
+- (void) appendMarkerItem: (PYMarkerItem *) item
+{
+    [_items addObject: item];
 }
 
-- (void) setMarkerItem: (PYMarkerItem *) item
+- (void) clearMarkerItems
 {
-    [_item release];
-    _item = [item retain];
+    [_items removeAllObjects];
 }
 
 - (void) dealloc
 {
-    [_item release];
+    [_items release];
     [_hanAttributes release];
     [_pyAttributes release];
     </diff>
      <filename>PYView.m</filename>
    </modified>
    <modified>
      <diff>@@ -104,13 +104,18 @@ int main(int argc, char *argv[])
     view = [[PYView alloc] initWithFrame: viewRect
                                 fontName: @&quot;FZKai-Z03&quot;
                                    color: [NSColor whiteColor]];
-    NSArray *pinyin = [NSArray arrayWithObjects: @&quot;ni&#780;&quot;, @&quot;ha&#780;o&quot;, @&quot;zho&#772;ng&quot;, @&quot;hua&#769;&quot;, 
-                       @&quot;r&#233;n&quot;, @&quot;m&#237;n&quot;, @&quot;go&#768;ng&quot;, @&quot;h&#233;&quot;, @&quot;guo&#769;&quot;, nil];
-    PYMarkerItem *item = [[PYMarkerItem alloc] initWithHanzi: @&quot;&#20320;&#22909;&#20013;&#21326;&#20154;&#27665;&#20849;&#21644;&#22269;&quot;
-                                                      pinyin: pinyin
-                                                        type: 1];
-    [view setMarkerItem: item];
-    [item release];
+
+    NSArray *pinyin1 = [NSArray arrayWithObjects: @&quot;ni&#780;&quot;, @&quot;ha&#780;o&quot;, nil];
+    NSArray *pinyin2 = [NSArray arrayWithObjects: @&quot;zho&#772;ng&quot;, @&quot;hua&#769;&quot;,
+                        @&quot;r&#233;n&quot;, @&quot;m&#237;n&quot;, @&quot;go&#768;ng&quot;, @&quot;h&#233;&quot;, @&quot;guo&#769;&quot;, nil];
+
+
+    [view appendMarkerItem: [PYMarkerItem itemWithHanzi: @&quot;&#20320;&#22909;&quot;
+                                                 pinyin: pinyin1
+                                                   type: 1]];
+    [view appendMarkerItem: [PYMarkerItem itemWithHanzi: @&quot;&#20013;&#21326;&#20154;&#27665;&#20849;&#21644;&#22269;&quot;
+                                                 pinyin: pinyin2
+                                                   type: 1]];
 
     [[window contentView] addSubview: view];
     [window makeFirstResponder: view];    </diff>
      <filename>PYViewTest/main.m</filename>
    </modified>
    <modified>
      <diff>@@ -16,13 +16,18 @@ Basically, PYView can be embeded into your app like this:
     view = [[PYView alloc] initWithFrame: viewRect
                                 fontName: @&quot;FZKai-Z03&quot;
                                    color: [NSColor whiteColor]];
-    NSArray *pinyin = [NSArray arrayWithObjects: @&quot;ni&#780;&quot;, @&quot;ha&#780;o&quot;, @&quot;zho&#772;ng&quot;, @&quot;hua&#769;&quot;, 
-                       @&quot;r&#233;n&quot;, @&quot;m&#237;n&quot;, @&quot;go&#768;ng&quot;, @&quot;h&#233;&quot;, @&quot;guo&#769;&quot;, nil];
-    PYMarkerItem *item = [[PYMarkerItem alloc] initWithHanzi: @&quot;&#20320;&#22909;&#20013;&#21326;&#20154;&#27665;&#20849;&#21644;&#22269;&quot;
-                                                      pinyin: pinyin
-                                                        type: 1];
-    [view setMarkerItem: item];
-    [item release];
+
+    NSArray *pinyin1 = [NSArray arrayWithObjects: @&quot;ni&#780;&quot;, @&quot;ha&#780;o&quot;, nil];
+    NSArray *pinyin2 = [NSArray arrayWithObjects: @&quot;zho&#772;ng&quot;, @&quot;hua&#769;&quot;,
+                        @&quot;r&#233;n&quot;, @&quot;m&#237;n&quot;, @&quot;go&#768;ng&quot;, @&quot;h&#233;&quot;, @&quot;guo&#769;&quot;, nil];
+
+
+    [view appendMarkerItem: [PYMarkerItem itemWithHanzi: @&quot;&#20320;&#22909;&quot;
+                                                 pinyin: pinyin1
+                                                   type: 1]];
+    [view appendMarkerItem: [PYMarkerItem itemWithHanzi: @&quot;&#20013;&#21326;&#20154;&#27665;&#20849;&#21644;&#22269;&quot;
+                                                 pinyin: pinyin2
+                                                   type: 1]];
 
 For more details, check the PYViewTest project.
 </diff>
      <filename>README.markdown</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1d8c868d26b559d534fcac09e795629514c024a5</id>
    </parent>
  </parents>
  <author>
    <name>Jjgod Jiang</name>
    <email>gzjjgod@gmail.com</email>
  </author>
  <url>http://github.com/jjgod/pinyinview/commit/33d7d3ede7a250c2d8f1eeb293a1800f8a6b3533</url>
  <id>33d7d3ede7a250c2d8f1eeb293a1800f8a6b3533</id>
  <committed-date>2008-07-25T02:26:43-07:00</committed-date>
  <authored-date>2008-07-25T02:26:43-07:00</authored-date>
  <message>Add show multiple marker item.</message>
  <tree>e4286c19dfd4b5703b86375cbad395980bdd915a</tree>
  <committer>
    <name>Jjgod Jiang</name>
    <email>gzjjgod@gmail.com</email>
  </committer>
</commit>
