Class: Opine::Native::Window

Inherits:
Window show all
Defined in:
lib/opine/widgets/window_osx.rb,
lib/opine/widgets/window_win.rb

Direct Known Subclasses

Dark::Window

Defined Under Namespace

Classes: Window

Constant Summary

Constants inherited from Window

Window::DEFAULTS

Instance Attribute Summary

Attributes inherited from Window

#content_view, #frame, #title, #window

Instance Method Summary collapse

Methods inherited from Window

#table

Constructor Details

#initialize(options, &block) ⇒ Window

Returns a new instance of Window.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/opine/widgets/window_osx.rb', line 3

def initialize(options,&block)
  @window = Cocoa::NSWindow.alloc.initWithContentRect(options[:frame].native,
    styleMask: native_style,
    backing: NSBackingStoreBuffered,
    defer: false)

  super

  window.setMinSize NSSize.new(width: 200, height: 200)

  point = CGPoint.new
  point[:x] = 120.0
  point[:y] = 220.0
  window.cascadeTopLeftFromPoint point

  @content_view = Opine::View.new(window.contentView)

  instance_eval(&block) if block

  window.makeKeyAndOrderFront nil
end

Instance Method Details

#native_styleObject



25
26
27
# File 'lib/opine/widgets/window_osx.rb', line 25

def native_style
  NSTitledWindowMask | NSResizableWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask
end

#title=(name) ⇒ Object



29
30
31
# File 'lib/opine/widgets/window_osx.rb', line 29

def title= name
  window.setTitle name
end

#visible?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/opine/widgets/window_osx.rb', line 33

def visible?
  window.isVisible
end