teacup 2.1.13 → 2.1.14
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/teacup-ios/handler.rb +1 -1
- data/lib/teacup-osx/handler.rb +1 -1
- data/lib/teacup/calculations.rb +2 -2
- data/lib/teacup/core_extensions/view_getters.rb +2 -2
- data/lib/teacup/layout.rb +1 -1
- data/lib/teacup/stylesheet_extensions/constraints.rb +14 -2
- data/lib/teacup/teacup_controller.rb +1 -1
- data/lib/teacup/teacup_view.rb +3 -3
- data/lib/teacup/version.rb +1 -1
- data/spec/ios/calculations_spec.rb +5 -1
- data/spec/ios/layout_module_spec.rb +2 -2
- metadata +24 -79
- data/.gitignore +0 -8
- data/.travis.yml +0 -3
- data/CHANGES.md +0 -26
- data/Gemfile +0 -9
- data/Gemfile.lock +0 -18
- data/LICENSE +0 -26
- data/README.md +0 -1527
- data/Rakefile +0 -18
- data/resources/Default-568h@2x.png +0 -0
- data/samples/README.md +0 -15
- data/samples/ios/AutoLayout/Gemfile +0 -1
- data/samples/ios/AutoLayout/Gemfile.lock +0 -13
- data/samples/ios/AutoLayout/Rakefile +0 -13
- data/samples/ios/AutoLayout/app/app_delegate.rb +0 -12
- data/samples/ios/AutoLayout/app/root_controller.rb +0 -16
- data/samples/ios/AutoLayout/app/styles/root.rb +0 -29
- data/samples/ios/AutoLayout/lib/dummy.rb +0 -2
- data/samples/ios/AutoLayout/lib/handlers.rb +0 -3
- data/samples/ios/AutoLayout/lib/styles/base.rb +0 -33
- data/samples/ios/Hai/.gitignore +0 -5
- data/samples/ios/Hai/Gemfile +0 -1
- data/samples/ios/Hai/Gemfile.lock +0 -13
- data/samples/ios/Hai/Rakefile +0 -12
- data/samples/ios/Hai/app/app_delegate.rb +0 -9
- data/samples/ios/Hai/app/hai_controller.rb +0 -13
- data/samples/ios/Hai/app/styles/iphone.rb +0 -47
- data/samples/ios/Hai/resources/Default-568h@2x.png +0 -0
- data/samples/ios/sweettea-example/Gemfile +0 -5
- data/samples/ios/sweettea-example/Gemfile.lock +0 -23
- data/samples/ios/sweettea-example/Rakefile +0 -11
- data/samples/ios/sweettea-example/app/app_delegate.rb +0 -43
- data/samples/ios/sweettea-example/resources/Default-568h@2x.png +0 -0
- data/samples/osx/Tweets/Gemfile +0 -1
- data/samples/osx/Tweets/Gemfile.lock +0 -13
- data/samples/osx/Tweets/README +0 -7
- data/samples/osx/Tweets/Rakefile +0 -10
- data/samples/osx/Tweets/app/app_delegate.rb +0 -18
- data/samples/osx/Tweets/app/data_parser.rb +0 -10
- data/samples/osx/Tweets/app/json_parser.rb +0 -12
- data/samples/osx/Tweets/app/main_window.rb +0 -99
- data/samples/osx/Tweets/app/menu.rb +0 -108
- data/samples/osx/Tweets/app/stylesheet.rb +0 -21
- data/samples/osx/Tweets/app/tweet.rb +0 -11
- data/samples/osx/Tweets/resources/Credits.rtf +0 -29
- data/samples/osx/simple/.gitignore +0 -1
- data/samples/osx/simple/Gemfile +0 -1
- data/samples/osx/simple/Gemfile.lock +0 -16
- data/samples/osx/simple/Rakefile +0 -9
- data/samples/osx/simple/app/app_delegate.rb +0 -21
- data/samples/osx/simple/app/controller.rb +0 -11
- data/samples/osx/simple/app/menu.rb +0 -108
- data/samples/osx/simple/app/window.rb +0 -12
- data/samples/osx/simple/resources/Credits.rtf +0 -29
- data/samples/osx/simple/resources/teacup.png +0 -0
- data/teacup.gemspec +0 -25
@@ -1,12 +0,0 @@
|
|
1
|
-
class JSONParser
|
2
|
-
def self.parse_from_url(url)
|
3
|
-
data = DataParser.parse(url)
|
4
|
-
|
5
|
-
error_ptr = Pointer.new(:object)
|
6
|
-
json = NSJSONSerialization.JSONObjectWithData(data, options:0, error:error_ptr)
|
7
|
-
unless json
|
8
|
-
raise error_ptr[0]
|
9
|
-
end
|
10
|
-
json
|
11
|
-
end
|
12
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
class MainController < TeacupWindowController
|
2
|
-
stylesheet :main_window
|
3
|
-
|
4
|
-
layout do
|
5
|
-
@text_search = subview(NSTextField, :text_search,
|
6
|
-
stringValue: 'xcode crash'
|
7
|
-
)
|
8
|
-
|
9
|
-
subview(NSButton, :search_button,
|
10
|
-
action: 'search:',
|
11
|
-
target: self,
|
12
|
-
)
|
13
|
-
|
14
|
-
scroll_view = subview(NSScrollView, :scroll_view)
|
15
|
-
|
16
|
-
@table_view = subview(NSTableView, :table_view,
|
17
|
-
delegate: self,
|
18
|
-
dataSource: self,
|
19
|
-
)
|
20
|
-
|
21
|
-
column_avatar = NSTableColumn.alloc.initWithIdentifier("avatar")
|
22
|
-
column_avatar.editable = false
|
23
|
-
column_avatar.headerCell.setTitle("Avator")
|
24
|
-
column_avatar.setWidth(40)
|
25
|
-
column_avatar.setDataCell(NSImageCell.alloc.init)
|
26
|
-
@table_view.addTableColumn(column_avatar)
|
27
|
-
|
28
|
-
column_name = NSTableColumn.alloc.initWithIdentifier("name")
|
29
|
-
column_name.editable = false
|
30
|
-
column_name.headerCell.setTitle("Name")
|
31
|
-
column_name.setWidth(150)
|
32
|
-
@table_view.addTableColumn(column_name)
|
33
|
-
|
34
|
-
column_tweet = NSTableColumn.alloc.initWithIdentifier("tweet")
|
35
|
-
column_tweet.editable = false
|
36
|
-
column_tweet.headerCell.setTitle("Tweet")
|
37
|
-
column_tweet.setWidth(290)
|
38
|
-
@table_view.addTableColumn(column_tweet)
|
39
|
-
|
40
|
-
scroll_view.setDocumentView(@table_view)
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
def search(sender)
|
45
|
-
text = @text_search.stringValue
|
46
|
-
if text.length > 0
|
47
|
-
query = text.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
|
48
|
-
url = "http://search.twitter.com/search.json?q=#{query}"
|
49
|
-
|
50
|
-
Dispatch::Queue.concurrent.async do
|
51
|
-
json = nil
|
52
|
-
begin
|
53
|
-
json = JSONParser.parse_from_url(url)
|
54
|
-
rescue RuntimeError => e
|
55
|
-
presentError e.message
|
56
|
-
end
|
57
|
-
|
58
|
-
@search_result = []
|
59
|
-
json['results'].each do |dict|
|
60
|
-
tweet = Tweet.new(dict)
|
61
|
-
@search_result << tweet
|
62
|
-
|
63
|
-
Dispatch::Queue.concurrent.async do
|
64
|
-
profile_image_data = NSData.alloc.initWithContentsOfURL(NSURL.URLWithString(tweet.profile_image_url))
|
65
|
-
if profile_image_data
|
66
|
-
tweet.profile_image = NSImage.alloc.initWithData(profile_image_data)
|
67
|
-
Dispatch::Queue.main.sync do
|
68
|
-
@table_view.reloadData
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
Dispatch::Queue.main.sync { @table_view.reloadData }
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def numberOfRowsInTableView(aTableView)
|
81
|
-
return 0 if @search_result.nil?
|
82
|
-
return @search_result.size
|
83
|
-
end
|
84
|
-
|
85
|
-
def tableView(aTableView,
|
86
|
-
objectValueForTableColumn: aTableColumn,
|
87
|
-
row: rowIndex)
|
88
|
-
case aTableColumn.identifier
|
89
|
-
when "avatar"
|
90
|
-
return @search_result[rowIndex].profile_image
|
91
|
-
when "name"
|
92
|
-
return @search_result[rowIndex].author
|
93
|
-
when "tweet"
|
94
|
-
return @search_result[rowIndex].message
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
|
99
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
class AppDelegate
|
2
|
-
def buildMenu
|
3
|
-
@mainMenu = NSMenu.new
|
4
|
-
|
5
|
-
appName = NSBundle.mainBundle.infoDictionary['CFBundleName']
|
6
|
-
addMenu(appName) do
|
7
|
-
addItemWithTitle("About #{appName}", action: 'orderFrontStandardAboutPanel:', keyEquivalent: '')
|
8
|
-
addItem(NSMenuItem.separatorItem)
|
9
|
-
addItemWithTitle('Preferences', action: 'openPreferences:', keyEquivalent: ',')
|
10
|
-
addItem(NSMenuItem.separatorItem)
|
11
|
-
servicesItem = addItemWithTitle('Services', action: nil, keyEquivalent: '')
|
12
|
-
NSApp.servicesMenu = servicesItem.submenu = NSMenu.new
|
13
|
-
addItem(NSMenuItem.separatorItem)
|
14
|
-
addItemWithTitle("Hide #{appName}", action: 'hide:', keyEquivalent: 'h')
|
15
|
-
item = addItemWithTitle('Hide Others', action: 'hideOtherApplications:', keyEquivalent: 'H')
|
16
|
-
item.keyEquivalentModifierMask = NSCommandKeyMask|NSAlternateKeyMask
|
17
|
-
addItemWithTitle('Show All', action: 'unhideAllApplications:', keyEquivalent: '')
|
18
|
-
addItem(NSMenuItem.separatorItem)
|
19
|
-
addItemWithTitle("Quit #{appName}", action: 'terminate:', keyEquivalent: 'q')
|
20
|
-
end
|
21
|
-
|
22
|
-
addMenu('File') do
|
23
|
-
addItemWithTitle('New', action: 'newDocument:', keyEquivalent: 'n')
|
24
|
-
addItemWithTitle('Open…', action: 'openDocument:', keyEquivalent: 'o')
|
25
|
-
addItem(NSMenuItem.separatorItem)
|
26
|
-
addItemWithTitle('Close', action: 'performClose:', keyEquivalent: 'w')
|
27
|
-
addItemWithTitle('Save…', action: 'saveDocument:', keyEquivalent: 's')
|
28
|
-
addItemWithTitle('Revert to Saved', action: 'revertDocumentToSaved:', keyEquivalent: '')
|
29
|
-
addItem(NSMenuItem.separatorItem)
|
30
|
-
addItemWithTitle('Page Setup…', action: 'runPageLayout:', keyEquivalent: 'P')
|
31
|
-
addItemWithTitle('Print…', action: 'printDocument:', keyEquivalent: 'p')
|
32
|
-
end
|
33
|
-
|
34
|
-
addMenu('Edit') do
|
35
|
-
addItemWithTitle('Undo', action: 'undo:', keyEquivalent: 'z')
|
36
|
-
addItemWithTitle('Redo', action: 'redo:', keyEquivalent: 'Z')
|
37
|
-
addItem(NSMenuItem.separatorItem)
|
38
|
-
addItemWithTitle('Cut', action: 'cut:', keyEquivalent: 'x')
|
39
|
-
addItemWithTitle('Copy', action: 'copy:', keyEquivalent: 'c')
|
40
|
-
addItemWithTitle('Paste', action: 'paste:', keyEquivalent: 'v')
|
41
|
-
item = addItemWithTitle('Paste and Match Style', action: 'pasteAsPlainText:', keyEquivalent: 'V')
|
42
|
-
item.keyEquivalentModifierMask = NSCommandKeyMask|NSAlternateKeyMask
|
43
|
-
addItemWithTitle('Delete', action: 'delete:', keyEquivalent: '')
|
44
|
-
addItemWithTitle('Select All', action: 'selectAll:', keyEquivalent: 'a')
|
45
|
-
end
|
46
|
-
|
47
|
-
fontMenu = createMenu('Font') do
|
48
|
-
addItemWithTitle('Show Fonts', action: 'orderFrontFontPanel:', keyEquivalent: 't')
|
49
|
-
addItemWithTitle('Bold', action: 'addFontTrait:', keyEquivalent: 'b')
|
50
|
-
addItemWithTitle('Italic', action: 'addFontTrait:', keyEquivalent: 'b')
|
51
|
-
addItemWithTitle('Underline', action: 'underline:', keyEquivalent: 'u')
|
52
|
-
addItem(NSMenuItem.separatorItem)
|
53
|
-
addItemWithTitle('Bigger', action: 'modifyFont:', keyEquivalent: '+')
|
54
|
-
addItemWithTitle('Smaller', action: 'modifyFont:', keyEquivalent: '-')
|
55
|
-
end
|
56
|
-
|
57
|
-
textMenu = createMenu('Text') do
|
58
|
-
addItemWithTitle('Align Left', action: 'alignLeft:', keyEquivalent: '{')
|
59
|
-
addItemWithTitle('Center', action: 'alignCenter:', keyEquivalent: '|')
|
60
|
-
addItemWithTitle('Justify', action: 'alignJustified:', keyEquivalent: '')
|
61
|
-
addItemWithTitle('Align Right', action: 'alignRight:', keyEquivalent: '}')
|
62
|
-
addItem(NSMenuItem.separatorItem)
|
63
|
-
addItemWithTitle('Show Ruler', action: 'toggleRuler:', keyEquivalent: '')
|
64
|
-
addItemWithTitle('Copy Ruler', action: 'copyRuler:', keyEquivalent: 'c')
|
65
|
-
addItemWithTitle('Paste Ruler', action: 'pasteRuler:', keyEquivalent: 'v')
|
66
|
-
end
|
67
|
-
|
68
|
-
addMenu('Format') do
|
69
|
-
addItem fontMenu
|
70
|
-
addItem textMenu
|
71
|
-
end
|
72
|
-
|
73
|
-
addMenu('View') do
|
74
|
-
item = addItemWithTitle('Show Toolbar', action: 'toggleToolbarShown:', keyEquivalent: 't')
|
75
|
-
item.keyEquivalentModifierMask = NSCommandKeyMask|NSAlternateKeyMask
|
76
|
-
addItemWithTitle('Customize Toolbar…', action: 'runToolbarCustomizationPalette:', keyEquivalent: '')
|
77
|
-
end
|
78
|
-
|
79
|
-
NSApp.windowsMenu = addMenu('Window') do
|
80
|
-
addItemWithTitle('Minimize', action: 'performMiniaturize:', keyEquivalent: 'm')
|
81
|
-
addItemWithTitle('Zoom', action: 'performZoom:', keyEquivalent: '')
|
82
|
-
addItem(NSMenuItem.separatorItem)
|
83
|
-
addItemWithTitle('Bring All To Front', action: 'arrangeInFront:', keyEquivalent: '')
|
84
|
-
end.menu
|
85
|
-
|
86
|
-
NSApp.helpMenu = addMenu('Help') do
|
87
|
-
addItemWithTitle("#{appName} Help", action: 'showHelp:', keyEquivalent: '?')
|
88
|
-
end.menu
|
89
|
-
|
90
|
-
NSApp.mainMenu = @mainMenu
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
|
95
|
-
def addMenu(title, &b)
|
96
|
-
item = createMenu(title, &b)
|
97
|
-
@mainMenu.addItem item
|
98
|
-
item
|
99
|
-
end
|
100
|
-
|
101
|
-
def createMenu(title, &b)
|
102
|
-
menu = NSMenu.alloc.initWithTitle(title)
|
103
|
-
menu.instance_eval(&b) if b
|
104
|
-
item = NSMenuItem.alloc.initWithTitle(title, action: nil, keyEquivalent: '')
|
105
|
-
item.submenu = menu
|
106
|
-
item
|
107
|
-
end
|
108
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
Teacup::Stylesheet.new :main_window do
|
2
|
-
|
3
|
-
style :text_search,
|
4
|
-
frame: NSMakeRect(20, 318, 341, 22),
|
5
|
-
autoresizingMask: autoresize.fill_top
|
6
|
-
|
7
|
-
style :search_button,
|
8
|
-
frame: NSMakeRect(384, 310, 82, 32),
|
9
|
-
title: "Search",
|
10
|
-
bezelStyle: NSRoundedBezelStyle,
|
11
|
-
autoresizingMask: autoresize.fixed_top_right
|
12
|
-
|
13
|
-
style :scroll_view,
|
14
|
-
frame: NSMakeRect(0, 0, 480, 300),
|
15
|
-
autoresizingMask: autoresize.fill,
|
16
|
-
hasVerticalScroller: true
|
17
|
-
|
18
|
-
style :table_view,
|
19
|
-
autoresizingMask: autoresize.fill
|
20
|
-
|
21
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class Tweet
|
2
|
-
attr_reader :author, :message, :profile_image_url
|
3
|
-
attr_accessor :profile_image
|
4
|
-
|
5
|
-
def initialize(dict)
|
6
|
-
@author = dict['from_user_name']
|
7
|
-
@message = dict['text']
|
8
|
-
@profile_image_url = dict['profile_image_url']
|
9
|
-
@profile_image = nil
|
10
|
-
end
|
11
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
|
2
|
-
{\colortbl;\red255\green255\blue255;}
|
3
|
-
\paperw9840\paperh8400
|
4
|
-
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
|
5
|
-
|
6
|
-
\f0\b\fs24 \cf0 Engineering:
|
7
|
-
\b0 \
|
8
|
-
Some people\
|
9
|
-
\
|
10
|
-
|
11
|
-
\b Human Interface Design:
|
12
|
-
\b0 \
|
13
|
-
Some other people\
|
14
|
-
\
|
15
|
-
|
16
|
-
\b Testing:
|
17
|
-
\b0 \
|
18
|
-
Hopefully not nobody\
|
19
|
-
\
|
20
|
-
|
21
|
-
\b Documentation:
|
22
|
-
\b0 \
|
23
|
-
Whoever\
|
24
|
-
\
|
25
|
-
|
26
|
-
\b With special thanks to:
|
27
|
-
\b0 \
|
28
|
-
Mom\
|
29
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
.dat*
|
data/samples/osx/simple/Gemfile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
gem 'teacup', :path => '../../..'
|
data/samples/osx/simple/Rakefile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
|
2
|
-
class AppDelegate
|
3
|
-
def applicationDidFinishLaunching(notification)
|
4
|
-
buildMenu
|
5
|
-
buildWindow
|
6
|
-
end
|
7
|
-
|
8
|
-
def buildWindow
|
9
|
-
@controller = MainWindowController.new
|
10
|
-
@mainWindow = @controller.window
|
11
|
-
@table_view_controller = MainTableController.new
|
12
|
-
|
13
|
-
# @mainWindow = NSWindow.alloc.initWithContentRect([[240, 180], [480, 360]],
|
14
|
-
# styleMask: NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask,
|
15
|
-
# backing: NSBackingStoreBuffered,
|
16
|
-
# defer: false)
|
17
|
-
@mainWindow.title = NSBundle.mainBundle.infoDictionary['CFBundleName']
|
18
|
-
@mainWindow.orderFrontRegardless
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
class AppDelegate
|
2
|
-
def buildMenu
|
3
|
-
@mainMenu = NSMenu.new
|
4
|
-
|
5
|
-
appName = NSBundle.mainBundle.infoDictionary['CFBundleName']
|
6
|
-
addMenu(appName) do
|
7
|
-
addItemWithTitle("About #{appName}", action: 'orderFrontStandardAboutPanel:', keyEquivalent: '')
|
8
|
-
addItem(NSMenuItem.separatorItem)
|
9
|
-
addItemWithTitle('Preferences', action: 'openPreferences:', keyEquivalent: ',')
|
10
|
-
addItem(NSMenuItem.separatorItem)
|
11
|
-
servicesItem = addItemWithTitle('Services', action: nil, keyEquivalent: '')
|
12
|
-
NSApp.servicesMenu = servicesItem.submenu = NSMenu.new
|
13
|
-
addItem(NSMenuItem.separatorItem)
|
14
|
-
addItemWithTitle("Hide #{appName}", action: 'hide:', keyEquivalent: 'h')
|
15
|
-
item = addItemWithTitle('Hide Others', action: 'hideOtherApplications:', keyEquivalent: 'H')
|
16
|
-
item.keyEquivalentModifierMask = NSCommandKeyMask|NSAlternateKeyMask
|
17
|
-
addItemWithTitle('Show All', action: 'unhideAllApplications:', keyEquivalent: '')
|
18
|
-
addItem(NSMenuItem.separatorItem)
|
19
|
-
addItemWithTitle("Quit #{appName}", action: 'terminate:', keyEquivalent: 'q')
|
20
|
-
end
|
21
|
-
|
22
|
-
addMenu('File') do
|
23
|
-
addItemWithTitle('New', action: 'newDocument:', keyEquivalent: 'n')
|
24
|
-
addItemWithTitle('Open…', action: 'openDocument:', keyEquivalent: 'o')
|
25
|
-
addItem(NSMenuItem.separatorItem)
|
26
|
-
addItemWithTitle('Close', action: 'performClose:', keyEquivalent: 'w')
|
27
|
-
addItemWithTitle('Save…', action: 'saveDocument:', keyEquivalent: 's')
|
28
|
-
addItemWithTitle('Revert to Saved', action: 'revertDocumentToSaved:', keyEquivalent: '')
|
29
|
-
addItem(NSMenuItem.separatorItem)
|
30
|
-
addItemWithTitle('Page Setup…', action: 'runPageLayout:', keyEquivalent: 'P')
|
31
|
-
addItemWithTitle('Print…', action: 'printDocument:', keyEquivalent: 'p')
|
32
|
-
end
|
33
|
-
|
34
|
-
addMenu('Edit') do
|
35
|
-
addItemWithTitle('Undo', action: 'undo:', keyEquivalent: 'z')
|
36
|
-
addItemWithTitle('Redo', action: 'redo:', keyEquivalent: 'Z')
|
37
|
-
addItem(NSMenuItem.separatorItem)
|
38
|
-
addItemWithTitle('Cut', action: 'cut:', keyEquivalent: 'x')
|
39
|
-
addItemWithTitle('Copy', action: 'copy:', keyEquivalent: 'c')
|
40
|
-
addItemWithTitle('Paste', action: 'paste:', keyEquivalent: 'v')
|
41
|
-
item = addItemWithTitle('Paste and Match Style', action: 'pasteAsPlainText:', keyEquivalent: 'V')
|
42
|
-
item.keyEquivalentModifierMask = NSCommandKeyMask|NSAlternateKeyMask
|
43
|
-
addItemWithTitle('Delete', action: 'delete:', keyEquivalent: '')
|
44
|
-
addItemWithTitle('Select All', action: 'selectAll:', keyEquivalent: 'a')
|
45
|
-
end
|
46
|
-
|
47
|
-
fontMenu = createMenu('Font') do
|
48
|
-
addItemWithTitle('Show Fonts', action: 'orderFrontFontPanel:', keyEquivalent: 't')
|
49
|
-
addItemWithTitle('Bold', action: 'addFontTrait:', keyEquivalent: 'b')
|
50
|
-
addItemWithTitle('Italic', action: 'addFontTrait:', keyEquivalent: 'b')
|
51
|
-
addItemWithTitle('Underline', action: 'underline:', keyEquivalent: 'u')
|
52
|
-
addItem(NSMenuItem.separatorItem)
|
53
|
-
addItemWithTitle('Bigger', action: 'modifyFont:', keyEquivalent: '+')
|
54
|
-
addItemWithTitle('Smaller', action: 'modifyFont:', keyEquivalent: '-')
|
55
|
-
end
|
56
|
-
|
57
|
-
textMenu = createMenu('Text') do
|
58
|
-
addItemWithTitle('Align Left', action: 'alignLeft:', keyEquivalent: '{')
|
59
|
-
addItemWithTitle('Center', action: 'alignCenter:', keyEquivalent: '|')
|
60
|
-
addItemWithTitle('Justify', action: 'alignJustified:', keyEquivalent: '')
|
61
|
-
addItemWithTitle('Align Right', action: 'alignRight:', keyEquivalent: '}')
|
62
|
-
addItem(NSMenuItem.separatorItem)
|
63
|
-
addItemWithTitle('Show Ruler', action: 'toggleRuler:', keyEquivalent: '')
|
64
|
-
addItemWithTitle('Copy Ruler', action: 'copyRuler:', keyEquivalent: 'c')
|
65
|
-
addItemWithTitle('Paste Ruler', action: 'pasteRuler:', keyEquivalent: 'v')
|
66
|
-
end
|
67
|
-
|
68
|
-
addMenu('Format') do
|
69
|
-
addItem fontMenu
|
70
|
-
addItem textMenu
|
71
|
-
end
|
72
|
-
|
73
|
-
addMenu('View') do
|
74
|
-
item = addItemWithTitle('Show Toolbar', action: 'toggleToolbarShown:', keyEquivalent: 't')
|
75
|
-
item.keyEquivalentModifierMask = NSCommandKeyMask|NSAlternateKeyMask
|
76
|
-
addItemWithTitle('Customize Toolbar…', action: 'runToolbarCustomizationPalette:', keyEquivalent: '')
|
77
|
-
end
|
78
|
-
|
79
|
-
NSApp.windowsMenu = addMenu('Window') do
|
80
|
-
addItemWithTitle('Minimize', action: 'performMiniaturize:', keyEquivalent: 'm')
|
81
|
-
addItemWithTitle('Zoom', action: 'performZoom:', keyEquivalent: '')
|
82
|
-
addItem(NSMenuItem.separatorItem)
|
83
|
-
addItemWithTitle('Bring All To Front', action: 'arrangeInFront:', keyEquivalent: '')
|
84
|
-
end.menu
|
85
|
-
|
86
|
-
NSApp.helpMenu = addMenu('Help') do
|
87
|
-
addItemWithTitle("#{appName} Help", action: 'showHelp:', keyEquivalent: '?')
|
88
|
-
end.menu
|
89
|
-
|
90
|
-
NSApp.mainMenu = @mainMenu
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
|
95
|
-
def addMenu(title, &b)
|
96
|
-
item = createMenu(title, &b)
|
97
|
-
@mainMenu.addItem item
|
98
|
-
item
|
99
|
-
end
|
100
|
-
|
101
|
-
def createMenu(title, &b)
|
102
|
-
menu = NSMenu.alloc.initWithTitle(title)
|
103
|
-
menu.instance_eval(&b) if b
|
104
|
-
item = NSMenuItem.alloc.initWithTitle(title, action: nil, keyEquivalent: '')
|
105
|
-
item.submenu = menu
|
106
|
-
item
|
107
|
-
end
|
108
|
-
end
|