Class: Smagacor::SmagacorWindow

Inherits:
FXMainWindow
  • Object
show all
Defined in:
lib/smagacor/smagacor-ui.rb

Overview

Main window for Smagacor.

Constant Summary collapse

DESCRIPTION =

Small description of Smagacor, for the about view.

"\n\nSmagacor #{::Smagacor::VERSION.join('.')}

Smagacor is a collection of some small games.
It provides an easy interface for adding new games and has
a pleasing :-) appearance.

Select a game from the menu on the left side!
And have fun with Smagacor!!!

smagacor.rubyforge.org"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, controller) ⇒ SmagacorWindow

Create the main window, using app [FXApplication] and controller [Controller].



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/smagacor/smagacor-ui.rb', line 172

def initialize( app, controller )
  super( app, "Smagacor Game Collection", nil, nil, DECOR_ALL, 100, 100, 800, 600 )
  @controller = controller

  @logwindow = LogWindow.new( app )
  logger.set_log_dev( @logwindow )

  menubar = FXMenubar.new( self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X )

  filemenu = FXMenuPane.new( self )
  FXMenuCommand.new( filemenu, "Quit\tCtl-Q", nil, getApp(), FXApp::ID_QUIT )
  FXMenuTitle.new( menubar, "&File", nil, filemenu )

  editmenu = FXMenuPane.new( self )
  FXMenuCommand.new( editmenu, "Undo\tCtl-Z" ).connect( SEL_COMMAND, method( :onUndo ) )
  FXMenuTitle.new( menubar, "&Edit", nil, editmenu )

  helpmenu = FXMenuPane.new( self )
  FXMenuCommand.new( helpmenu, "Log Window...\tCtl-L" ).connect( SEL_COMMAND ) { @logwindow.show }
  FXMenuCommand.new( helpmenu, "About Smagacor\tCtl-A" ).connect( SEL_COMMAND ) { @switcher.current = 0 }
  FXMenuTitle.new( menubar, "&Help", nil, helpmenu )

  status = FXStatusbar.new( self, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|STATUSBAR_WITH_DRAGCORNER )

  splitter = FXSplitter.new( self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y|SPLITTER_TRACKING )

  @shutter = GameMenuShutter.new( splitter )
  @switcher = GameSwitcher.new( splitter )
  @shutter.init_game_list( @switcher, controller )

  FXLabel.new( @switcher, DESCRIPTION, SmagacorWindow.load_image( getApp(), controller.get_file( 'smagacor.png' ) ), ICON_ABOVE_TEXT )
end

Class Method Details

.load_image(app, file) ⇒ Object

Used to load *.png images into FXPNGIcon objects.



164
165
166
167
168
169
# File 'lib/smagacor/smagacor-ui.rb', line 164

def self.load_image( app, file )
  img = FXPNGIcon.new( app, nil, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP )
  FXFileStream.open( file, FXStreamLoad ) {|str| img.loadPixels(str) }
  img.create
  img
end

Instance Method Details

#createObject



205
206
207
208
209
# File 'lib/smagacor/smagacor-ui.rb', line 205

def create
  super
  @shutter.width = 150
  show
end

#onUndo(sender, sel, event) ⇒ Object



211
212
# File 'lib/smagacor/smagacor-ui.rb', line 211

def onUndo( sender, sel, event )
end