Sha256: 9382fe83a989c8f24645fa18f7deb05dce280f74e1145d63ce9ab7f09cd2424f

Contents?: true

Size: 965 Bytes

Versions: 1

Compression:

Stored size: 965 Bytes

Contents

# Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
# License: Ruby License

require "osx/cocoa"
require "sgl/sgl-color"
require "sgl/cocoa-event"
require "sgl/cocoa-window"
require "sgl/cocoa-draw"
require "sgl/cocoa-color"
require "sgl/cocoa-media"

module SGL
  class Application
    def initialize
      initialize_cocoa
      initialize_window
      initialize_color
      initialize_event
    end

    def initialize_cocoa
      OSX.ruby_thread_switcher_start(0.001, 0.01)
      Thread.abort_on_exception = true

      @app = OSX::NSApplication.sharedApplication
      mainmenu = OSX::NSMenu.alloc.init
      @app.setMainMenu(mainmenu)
    end
    private :initialize_cocoa

    def run
      OSX.NSApp.run
      OSX::NSEvent.stopPeriodicEvents
    end

    def stop
      close_window
      OSX.NSApp.stop(nil)
      OSX::NSEvent.startPeriodicEventsAfterDelay(0.01, :withPeriod, 0.01)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sgl-1.0.0 lib/sgl/cocoa-app.rb