Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (35 sloc) 1.39 KB
import "AppKit"
nsapp = NSApplication sharedApplication
\ Create the menubar
quitMenuItem = NSMenuItem new setTitle: "Quit «NSProcessInfo processInfo processName»";
setAction: #terminate:;
setKeyEquivalent: #q;
self
appMenu = NSMenu new addItem: quitMenuItem; self
appMenuItem = NSMenuItem new setSubmenu: appMenu; self
menuBar = NSMenu new addItem: appMenuItem; self
nsapp setMainMenu: menuBar
\ Create a little view
@TestView < NSView {
- init {
@gradient = NSGradient alloc initWithStartingColor: NSColor redColor
endingColor: NSColor yellowColor
^self
}
- drawRect: dirtyRect {
@gradient drawInRect: dirtyRect angle: 45
}
}
\ Create a window
win = (NSWindow alloc initWithContentRect: [NSZeroPoint, [300, 200]]
styleMask: (NSTitledWindowMask bitOr: NSResizableWindowMask)
backing: NSBackingStoreBuffered
defer: no)
setTitle: "Tranquil!";
setContentView: TestView new;
self
\ Start the app
win makeKeyAndOrderFront: nil
nsapp setActivationPolicy: NSApplicationActivationPolicyRegular
nsapp activateIgnoringOtherApps: yes
nsapp run