Sha256: c3a64b782840b06a7e50bdcbb85222193f45bce21d3a587a455e676d127da023

Contents?: true

Size: 922 Bytes

Versions: 1

Compression:

Stored size: 922 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-0.4.0 lib/sgl/cocoa-app.rb