Class: RandomAppWindowController
- Inherits:
-
ObjC::NSObject
- Object
- ObjC::NSObject
- RandomAppWindowController
- Defined in:
- app/random.rb
Overview
Aaron Hillegass’ RandomApp in 100% Ruby to see it the old-fashioned way, see Chapter 2 of Aaron’s book: “Cocoa Programming for Mac OS X, 2nd Edition”
Instance Attribute Summary collapse
-
#generateButton ⇒ Object
Returns the value of attribute generateButton.
-
#seedButton ⇒ Object
Returns the value of attribute seedButton.
-
#textField ⇒ Object
Returns the value of attribute textField.
-
#window ⇒ Object
Returns the value of attribute window.
Instance Method Summary collapse
Instance Attribute Details
#generateButton ⇒ Object
Returns the value of attribute generateButton.
5 6 7 |
# File 'app/random.rb', line 5 def generateButton @generateButton end |
#seedButton ⇒ Object
Returns the value of attribute seedButton.
5 6 7 |
# File 'app/random.rb', line 5 def seedButton @seedButton end |
#textField ⇒ Object
Returns the value of attribute textField.
5 6 7 |
# File 'app/random.rb', line 5 def textField @textField end |
#window ⇒ Object
Returns the value of attribute window.
5 6 7 |
# File 'app/random.rb', line 5 def window @window end |
Instance Method Details
#init ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/random.rb', line 7 def init super styleMask = ObjC::NSTitledWindowMask + ObjC::NSClosableWindowMask + ObjC::NSMiniaturizableWindowMask @window = with(ObjC::NSWindow.alloc.initWithContentRect_styleMask_backing_defer_( [300,200,340,120], styleMask, ObjC::NSBackingStoreBuffered, false)) do |w| w.set(:releasedWhenClosed => 0, :title => 'RandomApp') @view = with(ObjC::NSView.alloc.initWithFrame_(w.frame)) do |v| @seedButton = with(ObjC::NSButton.alloc.initWithFrame_([20,75,300,25])) do |b| b.set({ :title => "Seed random number generator with time", :action => "seed:", :target => self, :bezelStyle => ObjC::NSRoundedBezelStyle }) v.addSubview_ b end @generateButton = with(ObjC::NSButton.alloc.initWithFrame_([20,45,300,25])) do |b| b.set({ :title => "Generate random number", :action => "generate:", :target => self, :bezelStyle => ObjC::NSRoundedBezelStyle }) v.addSubview_ b end @textField = with(ObjC::NSTextField.alloc.initWithFrame_([20,20,300,20])) do |t| t.set({ :objectValue => ObjC::NSCalendarDate.calendarDate, :editable => false, :drawsBackground => false, :alignment => ObjC::NSCenterTextAlignment, :bezeled => false }) v.addSubview_ t end w.setContentView_ v end w.center w.makeKeyAndOrderFront_ self end self end |