📄 qqcell.mm
字号:
[self drawDecoration:[NSImage imageNamed:kImageMute] headRect:imgRect]; break; } } } // change frame [u setFrame:(frame + 1) index:0]; // get display setting BOOL bShowRealName = [cache showRealName]; BOOL bShowNickName = [cache showNickName]; BOOL bShowLevel = [cache showLevel]; BOOL bShowSignature = [cache showSignature]; BOOL bShowUserProperty = [cache showUserProperty]; BOOL bShowStatusMessage = [cache showStatusMessage]; // draw user property is necessary if(bShowUserProperty) { NSImage* imgProp = nil; if([u isMobileQQ]) imgProp = [NSImage imageNamed:kImageMobileQQ]; else if([u isBind]) imgProp = [NSImage imageNamed:kImageBindQQ]; if(imgProp) { NSSize size = [imgProp size]; [imgProp compositeToPoint:NSMakePoint(x - size.width - kSpacing, imgRect.origin.y) operation:NSCompositeSourceOver]; } } // get text x start x += imgRect.size.width + kSpacing; // get first line NSString* string = nil; if(bShowNickName) string = [u nick]; if(bShowRealName) { if(string == nil && ![[u remarkName] isEmpty]) string = [u remarkName]; else if(![[u remarkName] isEmpty]) string = [NSString stringWithFormat:@"%@ [%@]", string, [u remarkName]]; else string = [u nick]; } if(bShowLevel) { if(string == nil) string = [NSString stringWithFormat:@"(Level: %d)", [u level]]; else string = [NSString stringWithFormat:@"%@ (Level: %d)", string, [u level]]; } if(bShowStatusMessage && ![[u statusMessage] isEmpty]) { if(string == nil) string = [NSString stringWithFormat:@"(%@)", [u statusMessage]]; else string = [NSString stringWithFormat:@"%@ (%@)", string, [u statusMessage]]; } if(!bLarge && bShowSignature && [u signature]) string = [NSString stringWithFormat:@"%@ %@", string, [u signature]]; // get string attribute NSMutableDictionary* attributes = [NSMutableDictionary dictionary]; [attributes setObject:[FontTool nickFontWithPreference:m_QQ] forKey:NSFontAttributeName]; // set color, check online flag if([u onlining]) { int frame = [u frameArray][1] % 4; switch(frame) { case 0: [attributes setObject:[NSColor redColor] forKey:NSForegroundColorAttributeName]; break; case 1: [attributes setObject:[NSColor greenColor] forKey:NSForegroundColorAttributeName]; break; case 2: [attributes setObject:[NSColor blueColor] forKey:NSForegroundColorAttributeName]; break; case 3: [attributes setObject:[cache nickFontColor] forKey:NSForegroundColorAttributeName]; break; } [u setFrame:(frame + 1) index:1]; } else [attributes setObject:[cache nickFontColor] forKey:NSForegroundColorAttributeName]; // get string bound NSRect stringBound = [string boundingRectWithSize:NSMakeSize(10000, cellFrame.size.height) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes]; [string drawAtPoint:NSMakePoint(x, y) withAttributes:attributes]; // draw signature if need if(bLarge && bShowSignature && [u signature] && ![[u signature] isEmpty]) { // get signature attribute [attributes setObject:[FontTool signatureFontWithPreference:m_QQ] forKey:NSFontAttributeName]; [attributes setObject:[cache signatureFontColor] forKey:NSForegroundColorAttributeName]; y += stringBound.size.height; [[u signature] drawAtPoint:NSMakePoint(x, y) withAttributes:attributes]; }}- (void)drawMemberWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { if(m_searchStyle) { [self drawSearchStyleUserWithFrame:cellFrame inView:controlView]; return; } // get user object User* u = [self objectValue]; // head NSImage* imgMain = [u head:m_QQ handleStatus:YES]; imgMain = [ImageTool imageWithName:[imgMain name] size:kSizeSmall]; // get main image rect and draw NSSize imgSize = [imgMain size]; int x = (m_checkStyle ? [self drawChecker:cellFrame inView:controlView] : cellFrame.origin.x) + kSpacing; int y = NSMinY(cellFrame); NSRect imgRect = NSMakeRect(x, y, MIN(NSWidth(cellFrame), imgSize.width), MIN(NSHeight(cellFrame), imgSize.height)); if ([controlView isFlipped]) imgRect.origin.y += ceil((cellFrame.size.height + imgRect.size.height) / 2); else imgRect.origin.y += ceil((cellFrame.size.height - imgRect.size.height) / 2); [imgMain compositeToPoint:imgRect.origin operation:NSCompositeSourceOver]; // draw status decoration switch(m_status) { case kQQStatusAway: [self drawDecoration:[NSImage imageNamed:kImageAway] headRect:imgRect]; break; case kQQStatusHidden: [self drawDecoration:[NSImage imageNamed:kImageHidden] headRect:imgRect]; break; } // get display setting PreferenceCache* cache = [PreferenceCache cache:m_QQ]; BOOL bShowClusterNameCard = [cache showClusterNameCard]; // get text x start x += imgRect.size.width + kSpacing; // get name NSString* name = [u nick]; if(bShowClusterNameCard) { // get related cluster internal id int cId = m_internalId; if(cId == 0) { if([controlView isMemberOfClass:[NSOutlineView class]]) { NSOutlineView* outline = (NSOutlineView*)controlView; id dataSource = [outline dataSource]; if(dataSource) { id parent = [dataSource outlineView:outline parentOfItem:u]; while(parent && ![parent isMemberOfClass:[Cluster class]]) parent = [dataSource outlineView:outline parentOfItem:parent]; if(parent) cId = [(Cluster*)parent internalId]; } } } // if can't find parent cluster, don't append clustern name card if(cId != 0) { ClusterSpecificInfo* info = [u getClusterSpecificInfo:cId]; if(![[[info nameCard] name] isEmpty]) name = [NSString stringWithFormat:@"%@ [%@]", name, [[info nameCard] name]]; } } // get string attribute NSMutableDictionary* attributes = [NSMutableDictionary dictionary]; [attributes setObject:[FontTool nickFontWithPreference:m_QQ] forKey:NSFontAttributeName]; [attributes setObject:[cache nickFontColor] forKey:NSForegroundColorAttributeName]; // get string bound NSRect bound = [name boundingRectWithSize:cellFrame.size options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes]; // draw center vertical [name drawAtPoint:NSMakePoint(x, cellFrame.origin.y + MAX(0, (cellFrame.size.height - bound.size.height) / 2)) withAttributes:attributes];}- (void)drawClusterWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { // get cluster object Cluster* c = [self objectValue]; // check TM NSImage* imgMain = nil; if([c permanent]) imgMain = [ImageTool imageWithName:kImageCluster size:(m_largeClusterHeadStyle ? kSizeLarge : kSizeSmall)]; else imgMain = [ImageTool imageWithName:kImageTempCluster size:(m_largeClusterHeadStyle ? kSizeLarge : kSizeSmall)]; // get main image rect and draw NSSize imgSize = [imgMain size]; int x = (m_checkStyle ? [self drawChecker:cellFrame inView:controlView] : cellFrame.origin.x) + kSpacing; int y = NSMinY(cellFrame); NSRect imgRect = NSMakeRect(x, y, MIN(NSWidth(cellFrame), imgSize.width), MIN(NSHeight(cellFrame), imgSize.height)); if ([controlView isFlipped]) imgRect.origin.y += ceil((cellFrame.size.height + imgRect.size.height) / 2); else imgRect.origin.y += ceil((cellFrame.size.height - imgRect.size.height) / 2); [imgMain compositeToPoint:imgRect.origin operation:NSCompositeSourceOver]; // blink some icon if has message unread if([c permanent]) { if(!([c messageCount] > 0 && [c messageSetting] == kQQClusterMessageAccept && [c frame] == 1)) { // get cluster name NSString* name = nil; if([c name]) name = [c name]; else if([c externalId] != 0) name = [NSString stringWithFormat:@"%u", [c externalId]]; else name = [NSString stringWithFormat:@"%u", [c internalId]]; if([c messageSetting] == kQQClusterMessageDisplayCount && [c messageCount] > 0) name = [NSString stringWithFormat:@"%@ (%d)", name, [c messageCount]]; if(![[c operationSuffix] isEmpty]) name = [NSString stringWithFormat:@"%@ (%@)", name, [c operationSuffix]]; // get string attribute NSMutableDictionary* attributes = [NSMutableDictionary dictionary]; [attributes setObject:[FontTool nickFontWithPreference:m_QQ] forKey:NSFontAttributeName]; // set cluster to red if it's advanced cluster if([[c info] isAdvanced]) [attributes setObject:[NSColor redColor] forKey:NSForegroundColorAttributeName]; // get name bound NSRect bound = [name boundingRectWithSize:cellFrame.size options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes]; // draw name [name drawAtPoint:NSMakePoint(x + imgRect.size.width + kSpacing, MAX(0, y + (cellFrame.size.height - bound.size.height) / 2)) withAttributes:attributes]; } } else if([c messageCount] == 0 || [c frame] == 1) { // get cluster name NSString* name = [c name]; // append operation suffix if(![[c operationSuffix] isEmpty]) name = [NSString stringWithFormat:@"%@ (%@)", name, [c operationSuffix]]; // get string attribute NSMutableDictionary* attributes = [NSMutableDictionary dictionary]; [attributes setObject:[FontTool nickFontWithPreference:m_QQ] forKey:NSFontAttributeName]; // get name bound NSRect bound = [name boundingRectWithSize:cellFrame.size options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes]; // draw name [name drawAtPoint:NSMakePoint(x + imgRect.size.width + kSpacing, MAX(0, y + (cellFrame.size.height - bound.size.height) / 2)) withAttributes:attributes]; } [c setFrame:(([c frame] + 1) % 2)];}- (void)drawDummyWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { // get dummy object Dummy* dummy = [self objectValue]; // check TM NSImage* imgMain = [ImageTool imageWithName:kImageTempCluster size:kSizeSmall]; // get main image rect and draw NSSize imgSize = [imgMain size]; int x = cellFrame.origin.x + kSpacing; int y = NSMinY(cellFrame); NSRect imgRect = NSMakeRect(x, y, MIN(NSWidth(cellFrame), imgSize.width), MIN(NSHeight(cellFrame), imgSize.height)); if ([controlView isFlipped]) imgRect.origin.y += ceil((cellFrame.size.height + imgRect.size.height) / 2); else imgRect.origin.y += ceil((cellFrame.size.height - imgRect.size.height) / 2); [imgMain compositeToPoint:imgRect.origin operation:NSCompositeSourceOver]; // draw name NSString* name = [dummy name]; if(![[dummy operationSuffix] isEmpty]) name = [NSString stringWithFormat:@"%@ (%@)", name, [dummy operationSuffix]];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -