⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qqcell.mm

📁 lumaqq
💻 MM
📖 第 1 页 / 共 3 页
字号:
		// 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];		}- (void)drawOrganizationWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {	// get organization object	Organization* org = [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	if([org name] && ![[org name] isEmpty]) {		NSString* name = [org name];				// 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];		}}- (void)drawSearchUserResultWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {	id object = [self objectValue];	BOOL online = YES;	if([object isMemberOfClass:[AdvancedSearchedUser class]])		online = [(AdvancedSearchedUser*)object online];		// get head	NSImage* imgMain = [ImageTool headWithId:[object head] size:kSizeSmall];		// check online	if(!online)		imgMain = [ImageTool grayImage:imgMain 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];		// get text x start	x += imgRect.size.width + kSpacing;		// get qq string	NSString* qqStr = [NSString stringWithFormat:@"%u", [object QQ]];		// get string attribute	NSMutableDictionary* attributes = [NSMutableDictionary dictionary];	NSFont* font = [FontTool nickFontWithPreference:m_QQ];	font = [[NSFontManager sharedFontManager] convertFont:font toSize:[NSFont systemFontSize]];	[attributes setObject:font forKey:NSFontAttributeName];		// get string bound	NSRect bound = [qqStr boundingRectWithSize:cellFrame.size									   options:NSStringDrawingUsesLineFragmentOrigin									attributes:attributes];		// draw center vertical	[qqStr drawAtPoint:NSMakePoint(x, cellFrame.origin.y + MAX(0, (cellFrame.size.height - bound.size.height) / 2))		withAttributes:attributes];}- (void)drawSearchClusterResultWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {	id object = [self objectValue];		// get image	NSImage* imgMain = [ImageTool imageWithName:kImageCluster 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];		// get text x start	x += imgRect.size.width + kSpacing;		// get external id string	NSString* idStr = [NSString stringWithFormat:@"%u", [object externalId]];		// get string attribute	NSMutableDictionary* attributes = [NSMutableDictionary dictionary];	NSFont* font = [FontTool nickFontWithPreference:m_QQ];	font = [[NSFontManager sharedFontManager] convertFont:font toSize:[NSFont systemFontSize]];	[attributes setObject:font forKey:NSFontAttributeName];		// get string bound	NSRect bound = [idStr boundingRectWithSize:cellFrame.size									   options:NSStringDrawingUsesLineFragmentOrigin									attributes:attributes];		// draw center vertical	[idStr drawAtPoint:NSMakePoint(x, cellFrame.origin.y + MAX(0, (cellFrame.size.height - bound.size.height) / 2))		withAttributes:attributes];}- (int)drawChecker:(NSRect)cellFrame inView:(NSView*)controlView {	[m_checker setState:[self state:[self objectValue]]];	cellFrame.origin.x += kSpacing;	[m_checker drawWithFrame:cellFrame inView:controlView];	NSSize size = [m_checker cellSize];	return cellFrame.origin.x + size.width;}- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {	// if filtered, return	if(NSHeight(cellFrame) < kSizeSmall.height)		return;		id object = [self objectValue];	if([object isMemberOfClass:[Group class]])		[self drawGroupWithFrame:cellFrame inView:controlView];	else if([object isMemberOfClass:[User class]]) {		if(m_memberStyle)			[self drawMemberWithFrame:cellFrame inView:controlView];		else			[self drawUserWithFrame:cellFrame inView:controlView];	} else if([object isMemberOfClass:[Mobile class]])		[self drawMobileWithFrame:cellFrame inView:controlView];	else if([object isMemberOfClass:[Cluster class]])		[self drawClusterWithFrame:cellFrame inView:controlView];	else if([object isMemberOfClass:[Dummy class]])		[self drawDummyWithFrame:cellFrame inView:controlView];	else if([object isMemberOfClass:[Organization class]])		[self drawOrganizationWithFrame:cellFrame inView:controlView];	else if([object isMemberOfClass:[SearchedUser class]] || [object isMemberOfClass:[AdvancedSearchedUser class]])		[self drawSearchUserResultWithFrame:cellFrame inView:controlView];	else if([object isMemberOfClass:[ClusterInfo class]])		[self drawSearchClusterResultWithFrame:cellFrame inView:controlView];}- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)flag {	if(m_checkStyle) {		NSPoint locationInCellFrame = [controlView convertPoint:[theEvent locationInWindow] fromView:nil];				NSSize size = [m_checker cellSize];		NSRect frame;		frame.origin.x = cellFrame.origin.x + kSpacing;		frame.origin.y = cellFrame.origin.y + (cellFrame.size.height - size.height) / 2;		frame.size = size;				if(NSPointInRect(locationInCellFrame, frame)) {			NSEvent* event = theEvent;			do {				switch([event type]) {					case NSLeftMouseDown:						id obj = [self objectValue];						[self set:obj state:([self state:obj] != 0 ? NSOffState : NSOnState)];						[(NSControl*)controlView updateCell:self];												// send notification						[[NSNotificationCenter defaultCenter] postNotificationName:kQQCellDidSelectedNotificationName																			object:self																		  userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:[self state:obj]], kUserInfoState, obj, kUserInfoObjectValue, nil]];						break;					case NSLeftMouseDragged:						break;					default:						return YES;				}			} while(event = [[controlView window] nextEventMatchingMask:(NSLeftMouseDraggedMask | NSLeftMouseUpMask) untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YES]);		}							return YES;	} else		return [super trackMouse:theEvent						  inRect:cellFrame						  ofView:controlView 					untilMouseUp:flag];}#pragma mark -#pragma mark actions- (IBAction)onCheck:(id)sender {	NSLog(@"action");}#pragma mark -#pragma mark getter and setter- (void)setQQ:(UInt32)QQ {	m_QQ = QQ;}- (void)setSearchStyle:(BOOL)flag {	m_searchStyle = flag;}- (void)setCheckStyle:(BOOL)flag {	m_checkStyle = flag;}- (void)setMemberStyle:(BOOL)flag {	m_memberStyle = flag;}- (void)setLargeClusterHeadStyle:(BOOL)flag {	m_largeClusterHeadStyle = flag;}- (void)setIgnoreLargeUserHeadPreference:(BOOL)flag {	m_ignoreLargeUserHeadPreference = flag;}- (void)setInternalId:(UInt32)internalId {	m_internalId = internalId;}- (NSMutableDictionary*)stateMap {	return m_stateMap;}- (void)setStateMap:(NSMutableDictionary*)map {	[map retain];	[m_stateMap release];	m_stateMap = map;}- (int)identifier {	return m_identifier;}#pragma mark -#pragma mark helper- (NSCellStateValue)state:(id)obj {	NSNumber* value = [m_stateMap objectForKey:obj];	if(value == nil)		return NSOffState;	else		return (NSCellStateValue)[value intValue];}- (void)set:(id)obj state:(NSCellStateValue)state {	[m_stateMap setObject:[NSNumber numberWithInt:state] forKey:obj];}- (void)setIdentifier:(int)identifier {	m_identifier = identifier;}- (void)clearState {	[m_stateMap removeAllObjects];}@end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -