Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
535 changes: 535 additions & 0 deletions MacOSMath.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions MacOSMathExample/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// AppDelegate.h
// MacOSMath
//
// Created by 安志钢 on 17-01-08.
// Copyright © 2017年 安志钢. All rights reserved.
//
// This software may be modified and distributed under the terms of the
// MIT license. See the LICENSE file for details.
//

#import <Cocoa/Cocoa.h>

@interface AppDelegate : NSObject <NSApplicationDelegate>

@end
41 changes: 41 additions & 0 deletions MacOSMathExample/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// AppDelegate.m
// MacOSMath
//
// Created by 安志钢 on 17-01-08.
// Copyright © 2017年 安志钢. All rights reserved.
//
// This software may be modified and distributed under the terms of the
// MIT license. See the LICENSE file for details.
//

#import "AppDelegate.h"
#import "MTMathUILabel.h"

@interface AppDelegate ()

@property (weak) IBOutlet NSWindow *window;
@property (weak) IBOutlet MTMathUILabel *screen;
@property (weak) IBOutlet NSTextField *inputTextField;

@end

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
}


- (void)applicationWillTerminate:(NSNotification *)aNotification
{
// Insert code here to tear down your application
}

- (IBAction)clickUpdateButton:(NSButton *)sender
{
self.screen.latex = self.inputTextField.stringValue;
}

@end
58 changes: 58 additions & 0 deletions MacOSMathExample/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
722 changes: 722 additions & 0 deletions MacOSMathExample/Base.lproj/MainMenu.xib

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions MacOSMathExample/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017年 安志钢. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
16 changes: 16 additions & 0 deletions MacOSMathExample/main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// main.m
// MacOSMath
//
// Created by 安志钢 on 17-01-08.
// Copyright © 2017年 安志钢. All rights reserved.
//
// This software may be modified and distributed under the terms of the
// MIT license. See the LICENSE file for details.
//

#import <Cocoa/Cocoa.h>

int main(int argc, const char * argv[]) {
return NSApplicationMain(argc, argv);
}
3 changes: 3 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Needed due to
# http://stackoverflow.com/questions/33395675/cocoapods-file-reference-is-a-member-of-multiple-groups
workspace 'iosMath.xcworkspace'
project 'iosMath.xcodeproj'

install! 'cocoapods', :deterministic_uuids => false

target 'iosMathExample' do
Expand Down
Empty file modified README.md
100644 → 100755
Empty file.
3 changes: 3 additions & 0 deletions iosMath.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions iosMath/render/MTConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// MTConfig.h
// MacOSMath
//
// Created by 安志钢 on 17-01-09.
//
// This software may be modified and distributed under the terms of the
// MIT license. See the LICENSE file for details.
//

// Make TARGET_OS_IPHONE macro visible.
#include <TargetConditionals.h>

// Type definitions.
#if TARGET_OS_IPHONE
// TARGET_OS_MAC is defined as 1 for both Mac OS and iOS,
// so TARGET_OS_IPHONE is reliable.
@import UIKit;

typedef UIView MTView;
typedef UIColor MTColor;
typedef UIBezierPath MTBezierPath;
typedef UIEdgeInsets MTEdgeInsets;
typedef UILabel MTLabel;
typedef CGRect MTRect;

#define MTEdgeInsetsZero UIEdgeInsetsZero
#define MTGraphicsGetCurrentContext() UIGraphicsGetCurrentContext()

#else
@import AppKit;
#import "NSBezierPath+addLineToPoint.h"
#import "NSView+backgroundColor.h"
#import "MTLabel.h"

typedef NSView MTView;
typedef NSColor MTColor;
typedef NSBezierPath MTBezierPath;
typedef NSEdgeInsets MTEdgeInsets;
typedef NSRect MTRect;

// For backward compatibility, DO NOT use NSEdgeInsetsZero (Available from OS X 10.10).
#define MTEdgeInsetsZero (NSEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f));
#define MTGraphicsGetCurrentContext() ([[NSGraphicsContext currentContext] graphicsPort])

#endif // TARGET_OS_IPHONE
5 changes: 5 additions & 0 deletions iosMath/render/MTFont.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ - (instancetype)initFontWithName:(NSString *)name size:(CGFloat)size

+ (NSBundle*) fontBundle
{
#if TARGET_OS_IPHONE
// Uses bundle for class so that this can be access by the unit tests.
return [NSBundle bundleWithURL:[[NSBundle bundleForClass:[self class]] URLForResource:@"iosMathFonts" withExtension:@"bundle"]];
#else
// TODO: Font bundle for Mac OS.
return [NSBundle mainBundle];
#endif
}

- (MTFont *)copyFontWithSize:(CGFloat)size
Expand Down
21 changes: 21 additions & 0 deletions iosMath/render/MTLabel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// MTLabel.h
// MacOSMath
//
// Created by 安志钢 on 17-01-09.
//
// This software may be modified and distributed under the terms of the
// MIT license. See the LICENSE file for details.
//

#include <TargetConditionals.h>

#if !TARGET_OS_IPHONE
@import AppKit;

@interface MTLabel : NSTextField

@property (strong) NSString *text;

@end
#endif
44 changes: 44 additions & 0 deletions iosMath/render/MTLabel.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// MTLabel.m
// MacOSMath
//
// Created by 安志钢 on 17-01-09.
//
// This software may be modified and distributed under the terms of the
// MIT license. See the LICENSE file for details.
//

#import "MTLabel.h"

#if !TARGET_OS_IPHONE
@implementation MTLabel

@synthesize bezeled, drawsBackground, editable, selectable, stringValue;

- (instancetype)init
{
self = [super init];

if (self != nil) {
super.bezeled = NO;
super.drawsBackground = NO;
super.editable = NO;
super.selectable = NO;
}

return self;
}

#pragma mark - Customized getter and setter methods for property text.
- (NSString *)text
{
return super.stringValue;
}

- (void)setText:(NSString *)text
{
super.stringValue = text;
}

@end
#endif
14 changes: 10 additions & 4 deletions iosMath/render/MTMathListDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
//
// Created by Kostub Deshmukh on 8/27/13.
// Copyright (C) 2013 MathChat
//
//
// This software may be modified and distributed under the terms of the
// MIT license. See the LICENSE file for details.
//

@import Foundation;
@import QuartzCore;
@import UIKit;

// This header file is imported by Foudation.
//#include <TargetConditionals.h>

#import "MTConfig.h"

#import "MTFont.h"
#import "MTMathList.h"
Expand All @@ -27,7 +31,9 @@ NS_ASSUME_NONNULL_BEGIN
- (CGRect) displayBounds;

/// For debugging. Shows the object in quick look in Xcode.
#if TARGET_OS_IPHONE
- (id) debugQuickLookObject;
#endif

/// The distance from the axis to the top of the display
@property (nonatomic, readonly) CGFloat ascent;
Expand All @@ -42,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Whether the display has a subscript/superscript following it.
@property (nonatomic, readonly) BOOL hasScript;
/// The text color for this display
@property (nonatomic, nullable) UIColor* textColor;
@property (nonatomic, nullable) MTColor *textColor;

@end

Expand Down Expand Up @@ -97,7 +103,7 @@ typedef NS_ENUM(unsigned int, MTLinePosition) {

- (instancetype)init NS_UNAVAILABLE;

/** A display representing the numerator of the fraction. It's position is relative
/** A display representing the numerator of the fraction. It's position is relative
to the parent and is not treated as a sub-display.
*/
@property (nonatomic, readonly) MTMathListDisplay* numerator;
Expand Down
Loading