Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Thant Thet Khin Zaw committed May 27, 2011
1 parent b8d11be commit 025fd9b
Show file tree
Hide file tree
Showing 4 changed files with 1,672 additions and 0 deletions.
19 changes: 19 additions & 0 deletions OSX/IMKBased/KeyMagic/KeyMagicUtil.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// KeyMagicUtil.h
// KeyMagic
//
// Created by Thant Thet Khin Zaw on 5/8/11.
// Copyright 2011 N/A. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#include "KeyMagicTypes.h"

@interface KeyMagicUtil : NSObject {

}

+(NSString*) getKeyboardNameOrTitle:(const InfoList&)infos pathName:(NSString*) filePath;
+(NSImage *) getIconImageFromKeyboard:(const InfoList&)infos;

@end
37 changes: 37 additions & 0 deletions OSX/IMKBased/KeyMagic/KeyMagicUtil.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// KeyMagicUtil.m
// KeyMagic
//
// Created by Thant Thet Khin Zaw on 5/8/11.
// Copyright 2011 N/A. All rights reserved.
//

#import "KeyMagicUtil.h"

@implementation KeyMagicUtil

+(NSString*) getKeyboardNameOrTitle:(const InfoList&)infos pathName:(NSString*) filePath
{
NSString * keyboardName;
if (infos.find('name') != infos.end()) {
Info name = infos.find('name')->second;
keyboardName = [NSString stringWithCString:name.data encoding:NSUTF8StringEncoding];
} else {
NSString * fileName = [filePath lastPathComponent];
keyboardName = [fileName substringToIndex:[fileName length] - 4];
}
return keyboardName;
}

+(NSImage *) getIconImageFromKeyboard:(const InfoList&)infos
{
if (infos.find('icon') != infos.end()) {
Info icon = infos.find('icon')->second;
NSData * data = [NSData dataWithBytes:icon.data length:icon.size];
NSImage * image = [[[NSImage new] autorelease] initWithData:data];
return image;
}
return nil;
}

@end
Loading

0 comments on commit 025fd9b

Please sign in to comment.